Skip to content

Commit 2ac023c

Browse files
committed
remove mandatory setters from interface
Use set functions instead when necessary
1 parent a9e49dd commit 2ac023c

File tree

6 files changed

+37
-30
lines changed

6 files changed

+37
-30
lines changed

Assets/FbxExporters/Editor/ConvertToPrefabSettings.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public class ConvertToPrefabSettings : ExportOptionsSettingsBase<ConvertToPrefab
8080
[System.Serializable]
8181
public class ConvertToPrefabSettingsSerialize : ExportOptionsSettingsSerializeBase
8282
{
83-
public override ExportSettings.Include ModelAnimIncludeOption { get { return ExportSettings.Include.ModelAndAnim; } set { } }
84-
public override ExportSettings.LODExportType LODExportType { get { return ExportSettings.LODExportType.All; } set { } }
85-
public override ExportSettings.ObjectPosition ObjectPosition { get { return ExportSettings.ObjectPosition.Reset; } set { } }
86-
public override bool ExportUnrendered { get { return true; } set { } }
83+
public override ExportSettings.Include ModelAnimIncludeOption { get { return ExportSettings.Include.ModelAndAnim; } }
84+
public override ExportSettings.LODExportType LODExportType { get { return ExportSettings.LODExportType.All; } }
85+
public override ExportSettings.ObjectPosition ObjectPosition { get { return ExportSettings.ObjectPosition.Reset; } }
86+
public override bool ExportUnrendered { get { return true; } }
8787
}
8888
}

Assets/FbxExporters/Editor/ExportModelEditorWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ protected int SetGameObjectsToExport(IEnumerable<UnityEngine.Object> toExport){
279279
private void SetAnimationExportType(bool isTimelineAnim){
280280
m_isTimelineAnim = isTimelineAnim;
281281
if (m_isTimelineAnim) {
282-
ExportSettings.instance.exportModelSettings.info.ModelAnimIncludeOption = ExportSettings.Include.Anim;
282+
ExportSettings.instance.exportModelSettings.info.SetModelAnimIncludeOption(ExportSettings.Include.Anim);
283283
}
284284
if (m_innerEditor) {
285285
var exportModelSettingsEditor = m_innerEditor as ExportModelSettingsEditor;

Assets/FbxExporters/Editor/ExportModelSettings.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ public override void OnInspectorGUI ()
100100
}
101101

102102
public interface IExportOptions {
103-
ExportSettings.ExportFormat ExportFormat { get; set; }
104-
ExportSettings.Include ModelAnimIncludeOption { get; set; }
105-
ExportSettings.LODExportType LODExportType { get; set; }
106-
ExportSettings.ObjectPosition ObjectPosition { get; set; }
107-
bool AnimateSkinnedMesh { get; set; }
108-
bool UseMayaCompatibleNames { get; set; }
109-
bool ExportUnrendered { get; set; }
103+
ExportSettings.ExportFormat ExportFormat { get; }
104+
ExportSettings.Include ModelAnimIncludeOption { get; }
105+
ExportSettings.LODExportType LODExportType { get; }
106+
ExportSettings.ObjectPosition ObjectPosition { get; }
107+
bool AnimateSkinnedMesh { get; }
108+
bool UseMayaCompatibleNames { get; }
109+
bool ExportUnrendered { get; }
110110
}
111111

112112
public abstract class ExportOptionsSettingsBase<T> : ScriptableObject where T : ExportOptionsSettingsSerializeBase, new()
@@ -125,13 +125,16 @@ public abstract class ExportOptionsSettingsSerializeBase : IExportOptions
125125
public bool animatedSkinnedMesh = true;
126126
public bool mayaCompatibleNaming = true;
127127

128-
public ExportSettings.ExportFormat ExportFormat { get { return exportFormat; } set { exportFormat = value; } }
129-
public bool AnimateSkinnedMesh { get { return animatedSkinnedMesh; } set { animatedSkinnedMesh = value; } }
130-
public bool UseMayaCompatibleNames { get { return mayaCompatibleNaming; } set { mayaCompatibleNaming = value; } }
131-
public abstract ExportSettings.Include ModelAnimIncludeOption { get; set; }
132-
public abstract ExportSettings.LODExportType LODExportType { get; set; }
133-
public abstract ExportSettings.ObjectPosition ObjectPosition { get; set; }
134-
public abstract bool ExportUnrendered { get; set; }
128+
public ExportSettings.ExportFormat ExportFormat { get { return exportFormat; } }
129+
public void SetExportFormat(ExportSettings.ExportFormat format){ this.exportFormat = format; }
130+
public bool AnimateSkinnedMesh { get { return animatedSkinnedMesh; } }
131+
public void SetAnimatedSkinnedMesh(bool animatedSkinnedMesh){ this.animatedSkinnedMesh = animatedSkinnedMesh; }
132+
public bool UseMayaCompatibleNames { get { return mayaCompatibleNaming; } }
133+
public void SetUseMayaCompatibleNames(bool useMayaCompNames){ this.mayaCompatibleNaming = useMayaCompNames; }
134+
public abstract ExportSettings.Include ModelAnimIncludeOption { get; }
135+
public abstract ExportSettings.LODExportType LODExportType { get; }
136+
public abstract ExportSettings.ObjectPosition ObjectPosition { get; }
137+
public abstract bool ExportUnrendered { get; }
135138
}
136139

137140
[System.Serializable]
@@ -142,9 +145,13 @@ public class ExportModelSettingsSerialize : ExportOptionsSettingsSerializeBase
142145
public ExportSettings.ObjectPosition objectPosition = ExportSettings.ObjectPosition.LocalCentered;
143146
public bool exportUnrendered = true;
144147

145-
public override ExportSettings.Include ModelAnimIncludeOption { get { return include; } set { include = value; } }
146-
public override ExportSettings.LODExportType LODExportType { get { return lodLevel; } set { lodLevel = value; } }
147-
public override ExportSettings.ObjectPosition ObjectPosition { get { return objectPosition; } set { objectPosition = value; } }
148-
public override bool ExportUnrendered { get { return exportUnrendered; } set { exportUnrendered = value; } }
148+
public override ExportSettings.Include ModelAnimIncludeOption { get { return include; } }
149+
public void SetModelAnimIncludeOption(ExportSettings.Include include) { this.include = include; }
150+
public override ExportSettings.LODExportType LODExportType { get { return lodLevel; } }
151+
public void SetLODExportType(ExportSettings.LODExportType lodLevel){ this.lodLevel = lodLevel; }
152+
public override ExportSettings.ObjectPosition ObjectPosition { get { return objectPosition; } }
153+
public void SetObjectPosition(ExportSettings.ObjectPosition objPos){ this.objectPosition = objPos; }
154+
public override bool ExportUnrendered { get { return exportUnrendered; } }
155+
public void SetExportUnredererd(bool exportUnrendered){ this.exportUnrendered = exportUnrendered; }
149156
}
150157
}

Assets/FbxExporters/Editor/UnitTests/DefaultSelectionTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace FbxExporters.UnitTests
1717
public class DefaultSelectionTest : ExporterTestBase
1818
{
1919
protected GameObject m_root;
20-
protected IExportOptions m_centerObjectsSetting;
20+
protected ExportModelSettingsSerialize m_centerObjectsSetting;
2121

2222
[SetUp]
2323
public override void Init ()
@@ -61,7 +61,7 @@ public void TestDefaultSelection ()
6161
Assert.IsNotNull (m_root);
6262

6363
// test without centered objects
64-
m_centerObjectsSetting.ObjectPosition = ExportSettings.ObjectPosition.WorldAbsolute;
64+
m_centerObjectsSetting.SetObjectPosition(ExportSettings.ObjectPosition.WorldAbsolute);
6565

6666
// test Export Root
6767
// Expected result: everything gets exported
@@ -96,7 +96,7 @@ public void TestDefaultSelection ()
9696
var goExportSet = new GameObject[]{ child2.gameObject, parent2.gameObject };
9797

9898
// test without centering objects
99-
m_centerObjectsSetting.ObjectPosition = ExportSettings.ObjectPosition.WorldAbsolute;
99+
m_centerObjectsSetting.SetObjectPosition(ExportSettings.ObjectPosition.WorldAbsolute);
100100

101101
exportedRoot = ExportSelection (exportSet, m_centerObjectsSetting);
102102
List<GameObject> children = new List<GameObject> ();
@@ -106,7 +106,7 @@ public void TestDefaultSelection ()
106106
CompareHierarchies (new GameObject[]{ child2, parent2.gameObject }, children.ToArray ());
107107

108108
// test with centered objects
109-
m_centerObjectsSetting.ObjectPosition = ExportSettings.ObjectPosition.LocalCentered;
109+
m_centerObjectsSetting.SetObjectPosition(ExportSettings.ObjectPosition.LocalCentered);
110110
var newCenter = FbxExporters.Editor.ModelExporter.FindCenter (goExportSet);
111111

112112
exportedRoot = ExportSelection (exportSet, m_centerObjectsSetting);

Assets/FbxExporters/Editor/UnitTests/ExporterTestBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ protected string ExportToFbx (
273273
){
274274
string filename = GetRandomFbxFilePath ();
275275
var exportOptions = new EditorTools.ExportModelSettingsSerialize ();
276-
exportOptions.LODExportType = lodExportType;
276+
exportOptions.SetLODExportType(lodExportType);
277277
if (animOnly) {
278-
exportOptions.ModelAnimIncludeOption = FbxExporters.EditorTools.ExportSettings.Include.Anim;
278+
exportOptions.SetModelAnimIncludeOption(FbxExporters.EditorTools.ExportSettings.Include.Anim);
279279
}
280280
var exportedFilePath = FbxExporters.Editor.ModelExporter.ExportObject (
281281
filename, hierarchy, exportOptions

Assets/FbxExporters/Editor/UnitTests/FbxAnimationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ public void AnimOnlyExportTest(string prefabPath)
836836
// get GameObject
837837
string filename = GetRandomFbxFilePath ();
838838
var exportOptions = new EditorTools.ExportModelSettingsSerialize ();
839-
exportOptions.ModelAnimIncludeOption = FbxExporters.EditorTools.ExportSettings.Include.Anim;
839+
exportOptions.SetModelAnimIncludeOption(FbxExporters.EditorTools.ExportSettings.Include.Anim);
840840
var exportedFilePath = ModelExporter.ExportObject (filename, originalGO, exportOptions);
841841
Assert.That (exportedFilePath, Is.EqualTo (filename));
842842

0 commit comments

Comments
 (0)