Skip to content

Commit f7a6b25

Browse files
committed
add export setting option for embedding textures
1 parent 4a061b7 commit f7a6b25

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ namespace FbxExporters.EditorTools {
99
[CustomEditor(typeof(ExportSettings))]
1010
public class ExportSettingsEditor : UnityEditor.Editor {
1111
public override void OnInspectorGUI() {
12-
ExportSettings temp = (ExportSettings)target;
12+
ExportSettings exportSettings = (ExportSettings)target;
1313

14-
temp.weldVertices = EditorGUILayout.Toggle ("Weld Vertices:", temp.weldVertices);
14+
exportSettings.weldVertices = EditorGUILayout.Toggle ("Weld Vertices:", exportSettings.weldVertices);
15+
exportSettings.embedTextures = EditorGUILayout.Toggle ("Embed Textures:", exportSettings.embedTextures);
1516

1617
if (GUI.changed) {
17-
EditorUtility.SetDirty (temp);
18-
temp.Dirty ();
18+
EditorUtility.SetDirty (exportSettings);
19+
exportSettings.Save ();
1920
}
2021
}
2122
}
@@ -24,6 +25,7 @@ public override void OnInspectorGUI() {
2425
public class ExportSettings : FbxExporters.EditorTools.ScriptableSingleton<ExportSettings>
2526
{
2627
public bool weldVertices = true;
28+
public bool embedTextures = false;
2729

2830
[MenuItem("Edit/Project Settings/Fbx Export", priority = 300)]
2931
static void ShowManager()
@@ -32,7 +34,7 @@ static void ShowManager()
3234
Selection.activeObject = instance;
3335
}
3436

35-
public void Dirty()
37+
public void Save()
3638
{
3739
instance.Save (true);
3840
}

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,13 +507,18 @@ public int ExportAll (IEnumerable<UnityEngine.Object> unityExportSet)
507507
fbxManager.SetIOSettings (FbxIOSettings.Create (fbxManager, Globals.IOSROOT));
508508

509509
// Export texture as embedded
510-
//fbxManager.GetIOSettings ().SetBoolProp (Globals.EXP_FBX_EMBEDDED, true);
510+
if(EditorTools.ExportSettings.instance.embedTextures){
511+
fbxManager.GetIOSettings ().SetBoolProp (Globals.EXP_FBX_EMBEDDED, true);
512+
}
511513

512514
// Create the exporter
513515
var fbxExporter = FbxExporter.Create (fbxManager, "Exporter");
514516

515517
// Initialize the exporter.
516-
int fileFormat = fbxManager.GetIOPluginRegistry ().FindWriterIDByDescription ("FBX ascii (*.fbx)");
518+
// fileFormat must be binary if we are embedding textures
519+
int fileFormat = EditorTools.ExportSettings.instance.embedTextures? -1 :
520+
fbxManager.GetIOPluginRegistry ().FindWriterIDByDescription ("FBX ascii (*.fbx)");
521+
517522
bool status = fbxExporter.Initialize (LastFilePath, fileFormat, fbxManager.GetIOSettings ());
518523
// Check that initialization of the fbxExporter was successful
519524
if (!status)

0 commit comments

Comments
 (0)