Skip to content

Commit dc1a48d

Browse files
committed
create convert to prefab settings objects
1 parent e2aebe2 commit dc1a48d

File tree

5 files changed

+117
-4
lines changed

5 files changed

+117
-4
lines changed

Assets/FbxExporters/Editor/ConvertToPrefabEditorWindow.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ protected override void OnEnable ()
3131
base.OnEnable ();
3232

3333
if (!m_innerEditor) {
34-
var ms = ExportSettings.instance.exportModelSettings;
34+
var ms = ExportSettings.instance.convertToPrefabSettings;
3535
if (!ms) {
3636
ExportSettings.LoadSettings ();
37-
ms = ExportSettings.instance.exportModelSettings;
37+
ms = ExportSettings.instance.convertToPrefabSettings;
3838
}
3939
m_innerEditor = UnityEditor.Editor.CreateEditor (ms);
40-
this.SetSingleHierarchyExport (m_singleHierarchyExport);
4140
}
4241
}
4342

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
namespace FbxExporters.EditorTools
5+
{
6+
[CustomEditor (typeof(ConvertToPrefabSettings))]
7+
public class ConvertToPrefabSettingsEditor : UnityEditor.Editor
8+
{
9+
private const float LabelWidth = 175;
10+
private const float FieldOffset = 18;
11+
12+
private string[] exportFormatOptions = new string[]{ "ASCII", "Binary" };
13+
private string[] includeOptions = new string[]{"Model(s) + Animation"};
14+
private string[] lodOptions = new string[]{"All Levels"};
15+
16+
private string[] objPositionOptions { get { return new string[]{"Local Pivot"}; }}
17+
18+
public override void OnInspectorGUI ()
19+
{
20+
var exportSettings = ((ConvertToPrefabSettings)target).info;
21+
22+
EditorGUIUtility.labelWidth = LabelWidth;
23+
24+
GUILayout.BeginHorizontal();
25+
EditorGUILayout.LabelField(new GUIContent("Export Format", "Export the FBX file in the standard binary format." +
26+
" Select ASCII to export the FBX file in ASCII format."), GUILayout.Width(LabelWidth - FieldOffset));
27+
exportSettings.exportFormat = (ExportModelSettingsSerialize.ExportFormat)EditorGUILayout.Popup((int)exportSettings.exportFormat, exportFormatOptions);
28+
GUILayout.EndHorizontal();
29+
30+
// always greyed out, show only to let user know what will happen
31+
EditorGUI.BeginDisabledGroup(true);
32+
GUILayout.BeginHorizontal();
33+
EditorGUILayout.LabelField(new GUIContent("Include", "Select whether to export models, animation or both."), GUILayout.Width(LabelWidth - FieldOffset));
34+
EditorGUILayout.Popup(0, includeOptions);
35+
GUILayout.EndHorizontal();
36+
37+
GUILayout.BeginHorizontal();
38+
EditorGUILayout.LabelField(new GUIContent("LOD level", "Select which LOD to export."), GUILayout.Width(LabelWidth - FieldOffset));
39+
EditorGUILayout.Popup(0, lodOptions);
40+
GUILayout.EndHorizontal();
41+
42+
GUILayout.BeginHorizontal();
43+
EditorGUILayout.LabelField(new GUIContent("Object(s) Position", "Select an option for exporting object's transform."), GUILayout.Width(LabelWidth - FieldOffset));
44+
EditorGUILayout.Popup(0, objPositionOptions);
45+
GUILayout.EndHorizontal();
46+
EditorGUI.EndDisabledGroup ();
47+
48+
// TODO: add implementation for these options, grey out in the meantime
49+
EditorGUI.BeginDisabledGroup (true);
50+
GUILayout.BeginHorizontal();
51+
EditorGUILayout.LabelField(new GUIContent("Transfer Root Motion To", "Select bone to transfer root motion animation to."), GUILayout.Width(LabelWidth - FieldOffset));
52+
EditorGUILayout.Popup(0, new string[]{"<None>"});
53+
GUILayout.EndHorizontal();
54+
55+
exportSettings.animatedSkinnedMesh = EditorGUILayout.Toggle ("Animated Skinned Mesh", exportSettings.animatedSkinnedMesh);
56+
EditorGUI.EndDisabledGroup ();
57+
58+
exportSettings.mayaCompatibleNaming = EditorGUILayout.Toggle (
59+
new GUIContent ("Compatible Naming:",
60+
"In Maya some symbols such as spaces and accents get replaced when importing an FBX " +
61+
"(e.g. \"foo bar\" becomes \"fooFBXASC032bar\"). " +
62+
"On export, convert the names of GameObjects so they are Maya compatible." +
63+
(exportSettings.mayaCompatibleNaming ? "" :
64+
"\n\nWARNING: Disabling this feature may result in lost material connections," +
65+
" and unexpected character replacements in Maya.")
66+
),
67+
exportSettings.mayaCompatibleNaming);
68+
}
69+
}
70+
71+
public class ConvertToPrefabSettings : ScriptableObject
72+
{
73+
public ConvertToPrefabSettingsSerialize info;
74+
75+
public ConvertToPrefabSettings ()
76+
{
77+
info = new ConvertToPrefabSettingsSerialize ();
78+
}
79+
}
80+
81+
[System.Serializable]
82+
public class ConvertToPrefabSettingsSerialize
83+
{
84+
public ExportModelSettingsSerialize.ExportFormat exportFormat = ExportModelSettingsSerialize.ExportFormat.ASCII;
85+
public string rootMotionTransfer = "";
86+
public bool animatedSkinnedMesh = true;
87+
public bool mayaCompatibleNaming = true;
88+
}
89+
}

Assets/FbxExporters/Editor/ConvertToPrefabSettings.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/ExportModelSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class ExportModelSettingsEditor : UnityEditor.Editor
1111

1212
private string[] exportFormatOptions = new string[]{ "ASCII", "Binary" };
1313
private string[] includeOptions = new string[]{"Model(s) Only", "Animation Only", "Model(s) + Animation"};
14-
private string[] lodOptions = new string[]{"All", "Highest", "Lowest"};
14+
private string[] lodOptions = new string[]{"All Levels", "Highest", "Lowest"};
1515

1616
public const string singleHierarchyOption = "Local Pivot";
1717
public const string multiHerarchyOption = "Local Centered";

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,12 @@ public static string[] DCCVendorLocations
451451
[SerializeField]
452452
private ExportModelSettingsSerialize exportModelSettingsSerialize;
453453

454+
[System.NonSerialized]
455+
public ConvertToPrefabSettings convertToPrefabSettings;
456+
457+
[SerializeField]
458+
private ConvertToPrefabSettingsSerialize convertToPrefabSettingsSerialize;
459+
454460
// ---------------- get functions for options in ExportModelSettings ----------------
455461
public static ExportModelSettingsSerialize.ExportFormat GetExportFormat(){
456462
return instance.exportModelSettings.info.exportFormat;
@@ -498,6 +504,8 @@ protected override void LoadDefaults()
498504
BakeAnimation = true;
499505
exportModelSettings = ScriptableObject.CreateInstance (typeof(ExportModelSettings)) as ExportModelSettings;
500506
exportModelSettingsSerialize = exportModelSettings.info;
507+
convertToPrefabSettings = ScriptableObject.CreateInstance (typeof(ConvertToPrefabSettings)) as ConvertToPrefabSettings;
508+
convertToPrefabSettingsSerialize = convertToPrefabSettings.info;
501509
}
502510

503511
/// <summary>
@@ -1234,11 +1242,17 @@ public static void LoadSettings(){
12341242
instance.exportModelSettings = ScriptableObject.CreateInstance (typeof(ExportModelSettings)) as ExportModelSettings;
12351243
}
12361244
instance.exportModelSettings.info = instance.exportModelSettingsSerialize;
1245+
1246+
if (!instance.convertToPrefabSettings) {
1247+
instance.convertToPrefabSettings = ScriptableObject.CreateInstance (typeof(ConvertToPrefabSettings)) as ConvertToPrefabSettings;
1248+
}
1249+
instance.convertToPrefabSettings.info = instance.convertToPrefabSettingsSerialize;
12371250
}
12381251

12391252
public void Save()
12401253
{
12411254
exportModelSettingsSerialize = exportModelSettings.info;
1255+
convertToPrefabSettingsSerialize = convertToPrefabSettings.info;
12421256
instance.Save (true);
12431257
}
12441258
}

0 commit comments

Comments
 (0)