Skip to content

Commit 790699c

Browse files
committed
merge
2 parents e702d95 + 9bfde82 commit 790699c

File tree

3 files changed

+83
-16
lines changed

3 files changed

+83
-16
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ***********************************************************************
1+
// ***********************************************************************
22
// Copyright (c) 2017 Unity Technologies. All rights reserved.
33
//
44
// Licensed under the ##LICENSENAME##.
@@ -88,7 +88,7 @@ public static GameObject[] CreateInstantiatedModelPrefab (GameObject [] unityGam
8888
// find common ancestor root & filePath;
8989
string[] filePaths = new string[gosToExport.Length];
9090
if (path==null)
91-
path = Path.Combine (Application.dataPath, "Objects");
91+
path = FbxExporters.EditorTools.ExportSettings.instance.convertToModelSavePath;
9292

9393
for(int n = 0; n < gosToExport.Length; n++){
9494
var filename = ModelExporter.ConvertToValidFilename (gosToExport [n].name + ".fbx");
@@ -310,4 +310,4 @@ private static void CopyComponents(GameObject from, GameObject to){
310310
}
311311
}
312312
}
313-
}
313+
}

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,82 @@ namespace FbxExporters.EditorTools {
88

99
[CustomEditor(typeof(ExportSettings))]
1010
public class ExportSettingsEditor : UnityEditor.Editor {
11+
Vector2 scrollPos = Vector2.zero;
12+
const float LabelWidth = 225;
13+
const float SelectableLabelMinWidth = 200;
14+
const float BrowseButtonWidth = 55;
15+
1116
public override void OnInspectorGUI() {
1217
ExportSettings exportSettings = (ExportSettings)target;
1318

1419
// Increasing the label width so that none of the text gets cut off
15-
EditorGUIUtility.labelWidth = 300;
20+
EditorGUIUtility.labelWidth = LabelWidth;
21+
22+
scrollPos = GUILayout.BeginScrollView (scrollPos);
1623

1724
exportSettings.weldVertices = EditorGUILayout.Toggle ("Weld Vertices:", exportSettings.weldVertices);
1825
exportSettings.embedTextures = EditorGUILayout.Toggle ("Embed Textures:", exportSettings.embedTextures);
1926
exportSettings.mayaCompatibleNames = EditorGUILayout.Toggle (
20-
new GUIContent("Convert to Maya Compatible Naming:",
27+
new GUIContent ("Convert to Maya Compatible Naming:",
2128
"In Maya some symbols such as spaces and accents get replaced when importing an FBX " +
2229
"(e.g. \"foo bar\" becomes \"fooFBXASC032bar\"). " +
2330
"On export, convert the names of GameObjects so they are Maya compatible." +
24-
(exportSettings.mayaCompatibleNames? "" :
31+
(exportSettings.mayaCompatibleNames ? "" :
2532
"\n\nWARNING: Disabling this feature may result in lost material connections," +
26-
" and unexpected character replacements in Maya.")
33+
" and unexpected character replacements in Maya.")
2734
),
2835
exportSettings.mayaCompatibleNames);
2936

37+
GUILayout.BeginHorizontal ();
38+
GUILayout.Label (new GUIContent (
39+
"Model Prefab Path:",
40+
"Relative path for saving Model Prefabs."));
41+
42+
EditorGUILayout.SelectableLabel(GetRelativePath(exportSettings.convertToModelSavePath, Application.dataPath),
43+
EditorStyles.textField, GUILayout.MinWidth(SelectableLabelMinWidth), GUILayout.Height(EditorGUIUtility.singleLineHeight));
44+
45+
if (GUILayout.Button ("Browse", EditorStyles.miniButton, GUILayout.Width (BrowseButtonWidth))) {
46+
string path = EditorUtility.OpenFolderPanel (
47+
"Select Model Prefabs Path", Application.dataPath, null
48+
);
49+
// Make sure something is selected, and that it is in the Asset folder
50+
if (!string.IsNullOrEmpty (path) && path.StartsWith (Application.dataPath)) {
51+
exportSettings.convertToModelSavePath = path;
52+
} else {
53+
Debug.LogWarning ("Please select a location in Assets/");
54+
}
55+
}
56+
57+
GUILayout.EndHorizontal ();
58+
GUILayout.FlexibleSpace ();
59+
GUILayout.EndScrollView ();
60+
3061
if (GUI.changed) {
3162
EditorUtility.SetDirty (exportSettings);
3263
exportSettings.Save ();
3364
}
3465
}
66+
67+
private string GetRelativePath(string filePath, string folder){
68+
Uri pathUri;
69+
try{
70+
pathUri = new Uri (filePath);
71+
}
72+
catch(UriFormatException){
73+
return filePath;
74+
}
75+
if (!folder.EndsWith (Path.DirectorySeparatorChar.ToString ())) {
76+
folder += Path.DirectorySeparatorChar;
77+
}
78+
Uri folderUri = new Uri (folder);
79+
string relativePath = Uri.UnescapeDataString (
80+
folderUri.MakeRelativeUri (pathUri).ToString ().Replace ('/', Path.DirectorySeparatorChar)
81+
);
82+
if (!relativePath.StartsWith ("Assets")) {
83+
relativePath = string.Format("Assets{0}{1}", Path.DirectorySeparatorChar, relativePath);
84+
}
85+
return relativePath;
86+
}
3587
}
3688

3789
[FilePath("ProjectSettings/FbxExportSettings.asset",FilePathAttribute.Location.ProjectFolder)]
@@ -40,6 +92,12 @@ public class ExportSettings : FbxExporters.EditorTools.ScriptableSingleton<Expor
4092
public bool weldVertices = true;
4193
public bool embedTextures = false;
4294
public bool mayaCompatibleNames = true;
95+
public string convertToModelSavePath;
96+
97+
void OnEnable()
98+
{
99+
convertToModelSavePath = Path.Combine (Application.dataPath, "Objects");
100+
}
43101

44102
[MenuItem("Edit/Project Settings/Fbx Export", priority = 300)]
45103
static void ShowManager()

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,34 @@ See LICENSE.md file in the project root for full license information.
88
Requirements
99
------------
1010

11-
* [FBX SDK C# Bindings v0.0.4a or higher](https://github.com/Unity-Technologies/FbxSharp)
11+
* [FBX SDK C# Bindings](https://github.com/Unity-Technologies/FbxSharp)
1212

1313
Packaging
1414
---------
1515

1616
**On OSX and Linux**
1717

18+
Get the source the first time.
1819
```
1920
# clone the source
2021
git clone https://github.com/Unity-Technologies/FbxExporters.git
22+
cd FbxExporters
23+
```
2124

22-
export PROJECT_PATH=~/Development/FbxExporters
23-
export UNITY3D_PATH=/Applications/Unity\ 2017.1.0f3/Unity.app/Contents/MacOS/Unity
24-
export PACKAGE_NAME=FbxExporters
25-
export PACKAGE_VERSION=0.0.5a
26-
export FBXSDK_PACKAGE_PATH=~/Development/FbxSharpBuild/FbxSdk_0.0.4a.unitypackage
27-
28-
"${UNITY3D_PATH}" -projectPath "${PROJECT_PATH}" -importPackage ${FBXSDK_PACKAGE_PATH} -quit
29-
"${UNITY3D_PATH}" -batchmode -projectPath "${PROJECT_PATH}" -exportPackage Assets/FbxExporters Assets/FbxSdk ${PROJECT_PATH}/${PACKAGE_NAME}_${PACKAGE_VERSION}.unitypackage -quit
25+
Update the source and package:
26+
```
27+
git pull
28+
PROJECT_PATH=`pwd`
29+
FBXSDK_PACKAGE_PATH=`ls -t ../FbxSharpBuild/FbxSdk_*.unitypackage | head -1`
30+
PACKAGE_VERSION=`echo "${FBXSDK_PACKAGE_PATH}" | sed -e 's/.*\([0-9]\{1,\}\.[0-9]*\.[0-9]*[a-z]*\).*/\1/'`
31+
32+
if test `uname -s` = 'Darwin' ; then
33+
UNITY_EDITOR_PATH=/Applications/Unity/Unity.app/Contents/MacOS/Unity
34+
else
35+
UNITY_EDITOR_PATH=/opt/Unity/Editor/Unity/Unity
36+
fi
37+
"${UNITY_EDITOR_PATH}" -projectPath "${PROJECT_PATH}" -importPackage "${FBXSDK_PACKAGE_PATH}" -quit
38+
"${UNITY_EDITOR_PATH}" -batchmode -projectPath "${PROJECT_PATH}" -exportPackage Assets/FbxExporters Assets/FbxSdk "${PROJECT_PATH}/FbxExporters_${PACKAGE_VERSION}.unitypackage" -quit
3039
```
3140

3241
**On Windows**

0 commit comments

Comments
 (0)