Skip to content

Commit 6b29736

Browse files
committed
refactor export model settings
1 parent 3050555 commit 6b29736

File tree

2 files changed

+30
-89
lines changed

2 files changed

+30
-89
lines changed

Assets/FbxExporters/Editor/ConvertToPrefabSettings.cs

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -74,48 +74,11 @@ public override void OnInspectorGUI ()
7474
}
7575
}
7676

77-
public class ConvertToPrefabSettings : ScriptableObject, IExportOptions
77+
public class ConvertToPrefabSettings : ExportOptionsSettingsBase<ConvertToPrefabSettingsSerialize>
7878
{
79-
public ConvertToPrefabSettingsSerialize info;
80-
81-
public ConvertToPrefabSettings ()
82-
{
83-
info = new ConvertToPrefabSettingsSerialize ();
84-
}
85-
86-
public ExportModelSettingsSerialize.ExportFormat GetExportFormat(){
87-
return info.exportFormat;
88-
}
89-
public ExportModelSettingsSerialize.Include GetModelAnimIncludeOption(){
90-
return ExportModelSettingsSerialize.Include.ModelAndAnim;
91-
}
92-
public ExportModelSettingsSerialize.LODExportType GetLODExportType(){
93-
return ExportModelSettingsSerialize.LODExportType.All;
94-
}
95-
public ExportModelSettingsSerialize.ObjectPosition GetObjectPosition(){
96-
return ExportModelSettingsSerialize.ObjectPosition.Reset;
97-
}
98-
public void SetObjectPosition(ExportModelSettingsSerialize.ObjectPosition objPos){
99-
// nothing to set
100-
return;
101-
}
102-
public bool AnimateSkinnedMesh(){
103-
return info.animatedSkinnedMesh;
104-
}
105-
public bool UseMayaCompatibleNames(){
106-
return info.mayaCompatibleNaming;
107-
}
108-
public bool ExportUnrendered(){
109-
return true;
110-
}
11179
}
11280

11381
[System.Serializable]
114-
public class ConvertToPrefabSettingsSerialize
115-
{
116-
public ExportModelSettingsSerialize.ExportFormat exportFormat = ExportModelSettingsSerialize.ExportFormat.ASCII;
117-
public string rootMotionTransfer = "";
118-
public bool animatedSkinnedMesh = true;
119-
public bool mayaCompatibleNaming = true;
120-
}
82+
public class ConvertToPrefabSettingsSerialize : ExportOptionsSettingsSerializeBase
83+
{}
12184
}

Assets/FbxExporters/Editor/ExportModelSettings.cs

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -100,59 +100,41 @@ public override void OnInspectorGUI ()
100100
}
101101

102102
public interface IExportOptions {
103-
ExportModelSettingsSerialize.ExportFormat GetExportFormat();
104-
ExportModelSettingsSerialize.Include GetModelAnimIncludeOption();
105-
ExportModelSettingsSerialize.LODExportType GetLODExportType();
106-
ExportModelSettingsSerialize.ObjectPosition GetObjectPosition();
107-
void SetObjectPosition(ExportModelSettingsSerialize.ObjectPosition objPos);
108-
bool AnimateSkinnedMesh();
109-
bool UseMayaCompatibleNames();
110-
bool ExportUnrendered();
103+
ExportModelSettingsSerialize.ExportFormat GetExportFormat { get; set; }
104+
ExportModelSettingsSerialize.Include GetModelAnimIncludeOption { get; set; }
105+
ExportModelSettingsSerialize.LODExportType GetLODExportType { get; set; }
106+
ExportModelSettingsSerialize.ObjectPosition GetObjectPosition { get; set; }
107+
bool AnimateSkinnedMesh { get; set; }
108+
bool UseMayaCompatibleNames { get; set; }
111109
}
112110

113-
public class ExportModelSettings : ScriptableObject, IExportOptions
111+
public abstract class ExportOptionsSettingsBase<T> : ScriptableObject, IExportOptions where T : ExportOptionsSettingsSerializeBase
114112
{
115-
public ExportModelSettingsSerialize info;
113+
public T info = new T();
114+
ExportModelSettingsSerialize.ExportFormat GetExportFormat { get { return info.exportFormat; } set { info.exportFormat = value; } }
115+
ExportModelSettingsSerialize.Include GetModelAnimIncludeOption { get; set; }
116+
ExportModelSettingsSerialize.LODExportType GetLODExportType { get; set; }
117+
ExportModelSettingsSerialize.ObjectPosition GetObjectPosition { get; set; }
118+
bool AnimateSkinnedMesh { get; set; }
119+
bool UseMayaCompatibleNames { get; set; }
120+
bool ExportUnrendered { get; set; }
121+
}
116122

117-
public ExportModelSettings ()
118-
{
119-
info = new ExportModelSettingsSerialize ();
120-
}
123+
public class ExportModelSettings : ExportOptionsSettingsBase<ExportModelSettingsSerialize>
124+
{
125+
}
121126

122-
public ExportModelSettingsSerialize.ExportFormat GetExportFormat(){
123-
return info.exportFormat;
124-
}
125-
public ExportModelSettingsSerialize.Include GetModelAnimIncludeOption(){
126-
return info.include;
127-
}
128-
public void SetModelAnimIncludeOption(ExportModelSettingsSerialize.Include include){
129-
info.include = include;
130-
}
131-
public ExportModelSettingsSerialize.LODExportType GetLODExportType(){
132-
return info.lodLevel;
133-
}
134-
public void SetLODExportType(ExportModelSettingsSerialize.LODExportType lodType){
135-
info.lodLevel = lodType;
136-
}
137-
public ExportModelSettingsSerialize.ObjectPosition GetObjectPosition(){
138-
return info.objectPosition;
139-
}
140-
public void SetObjectPosition(ExportModelSettingsSerialize.ObjectPosition objPos){
141-
info.objectPosition = objPos;
142-
}
143-
public bool AnimateSkinnedMesh(){
144-
return info.animatedSkinnedMesh;
145-
}
146-
public bool UseMayaCompatibleNames(){
147-
return info.mayaCompatibleNaming;
148-
}
149-
public bool ExportUnrendered(){
150-
return info.exportUnrendered;
151-
}
127+
[System.Serializable]
128+
public abstract class ExportOptionsSettingsSerializeBase
129+
{
130+
public ExportModelSettingsSerialize.ExportFormat exportFormat = ExportModelSettingsSerialize.ExportFormat.ASCII;
131+
public string rootMotionTransfer = "";
132+
public bool animatedSkinnedMesh = true;
133+
public bool mayaCompatibleNaming = true;
152134
}
153135

154136
[System.Serializable]
155-
public class ExportModelSettingsSerialize
137+
public class ExportModelSettingsSerialize : ExportOptionsSettingsSerializeBase
156138
{
157139
public enum ExportFormat { ASCII = 0, Binary = 1}
158140

@@ -162,13 +144,9 @@ public enum ObjectPosition { LocalCentered = 0, WorldAbsolute = 1, Reset = 2 /*
162144

163145
public enum LODExportType { All = 0, Highest = 1, Lowest = 2 }
164146

165-
public ExportFormat exportFormat = ExportFormat.ASCII;
166147
public Include include = Include.ModelAndAnim;
167148
public LODExportType lodLevel = LODExportType.All;
168149
public ObjectPosition objectPosition = ObjectPosition.LocalCentered;
169-
public string rootMotionTransfer = "";
170-
public bool animatedSkinnedMesh = true;
171-
public bool mayaCompatibleNaming = true;
172150
public bool exportUnrendered = true;
173151
}
174152
}

0 commit comments

Comments
 (0)