Skip to content

Commit 6d76850

Browse files
committed
create object to use for setting presets
simple scriptable object that contains the export settings, can create presets from it, and it's displayed in the export model options window
1 parent 7a10219 commit 6d76850

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

Assets/FbxExporters/Editor/ExportModelEditorWindow.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class ExportModelEditorWindow : EditorWindow
1919
private string m_exportFileName = "";
2020
private ModelExporter.AnimationExportType m_animExportType = ModelExporter.AnimationExportType.all;
2121

22+
private UnityEditor.Editor innerEditor;
23+
2224
public static void Init (string filename = "", ModelExporter.AnimationExportType exportType = ModelExporter.AnimationExportType.all)
2325
{
2426
ExportModelEditorWindow window = (ExportModelEditorWindow)EditorWindow.GetWindow <ExportModelEditorWindow>(WindowTitle, focus:true);
@@ -100,6 +102,17 @@ void OnGUI ()
100102
m_exportFileName = ModelExporter.ConvertToValidFilename(m_exportFileName);
101103
GUILayout.EndHorizontal ();
102104

105+
if (!innerEditor) {
106+
var ms = ExportSettings.instance.exportModelSettings;
107+
if (!ms) {
108+
ExportSettings.LoadSettings ();
109+
ms = ExportSettings.instance.exportModelSettings;
110+
}
111+
innerEditor = UnityEditor.Editor.CreateEditor (ms, editorType: typeof(ExportModelSettingsEditor));
112+
}
113+
innerEditor.DrawHeader ();
114+
innerEditor.OnInspectorGUI ();
115+
103116
GUILayout.FlexibleSpace ();
104117

105118
GUILayout.BeginHorizontal ();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
[CustomEditor(typeof(ExportModelSettings))]
5+
public class ExportModelSettingsEditor : UnityEditor.Editor {
6+
7+
public override void OnInspectorGUI() {
8+
var exportSettings = (ExportModelSettings)target;
9+
10+
exportSettings.info.test = EditorGUILayout.TextField (exportSettings.info.test);
11+
}
12+
}
13+
14+
public class ExportModelSettings : ScriptableObject {
15+
public ExportModelSettingsSerialize info;
16+
17+
public ExportModelSettings(){
18+
info = new ExportModelSettingsSerialize ();
19+
}
20+
}
21+
22+
[System.Serializable]
23+
public class ExportModelSettingsSerialize {
24+
public string test = "hi";
25+
26+
public ExportModelSettingsSerialize(){
27+
test = "hello";
28+
}
29+
}

Assets/FbxExporters/Editor/ExportModelSettings.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ public enum LODExportType {
482482
[SerializeField]
483483
private List<string> dccOptionPaths;
484484

485+
[System.NonSerialized]
486+
public ExportModelSettings exportModelSettings;
487+
488+
[SerializeField]
489+
private ExportModelSettingsSerialize exportModelSettingsSerialize;
490+
485491
protected override void LoadDefaults()
486492
{
487493
mayaCompatibleNames = true;
@@ -1224,11 +1230,20 @@ static void ShowManager()
12241230
{
12251231
instance.name = "Fbx Export Settings";
12261232
Selection.activeObject = instance;
1233+
LoadSettings ();
1234+
}
1235+
1236+
public static void LoadSettings(){
12271237
instance.Load();
1238+
if (!instance.exportModelSettings) {
1239+
instance.exportModelSettings = ScriptableObject.CreateInstance (typeof(ExportModelSettings)) as ExportModelSettings;
1240+
}
1241+
instance.exportModelSettings.info = instance.exportModelSettingsSerialize;
12281242
}
12291243

12301244
public void Save()
12311245
{
1246+
exportModelSettingsSerialize = exportModelSettings.info;
12321247
instance.Save (true);
12331248
}
12341249
}

0 commit comments

Comments
 (0)