Skip to content

Commit eeb0f31

Browse files
committed
clean up implementation
1 parent 79d6db6 commit eeb0f31

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,21 @@ protected override void LoadDefaults()
125125
mayaCompatibleNames = true;
126126
centerObjects = true;
127127
convertToModelSavePath = kDefaultSavePath;
128+
turntableScene = null;
129+
}
130+
131+
public static string GetTurnTableSceneName(){
132+
if (instance.turntableScene) {
133+
return instance.turntableScene.name;
134+
}
135+
return null;
136+
}
137+
138+
public static string GetTurnTableScenePath(){
139+
if (instance.turntableScene) {
140+
return AssetDatabase.GetAssetPath (instance.turntableScene);
141+
}
142+
return null;
128143
}
129144

130145
/// <summary>

Assets/FbxExporters/Editor/ReviewLastSavedModel.cs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class TurnTable
1515
{
1616
const string MenuItemName = "FbxExporters/Turntable Review/Autoload Last Saved Prefab";
1717

18-
const string ScenesPath = "Assets";
18+
const string DefaultScenesPath = "Assets";
19+
const string DefaultSceneName = "FbxExporters_TurnTableReview";
20+
1921
static string SceneName = "FbxExporters_TurnTableReview";
2022

2123
public const string TempSavePath = "_safe_to_delete";
@@ -53,7 +55,7 @@ private static System.IO.FileInfo GetLastSavedFile (string directoryPath, string
5355

5456
private static string GetSceneFilePath ()
5557
{
56-
return System.IO.Path.Combine (ScenesPath, SceneName + ".unity");
58+
return System.IO.Path.Combine (DefaultScenesPath, DefaultSceneName + ".unity");
5759
}
5860

5961
private static string GetLastSavedFilePath ()
@@ -151,42 +153,31 @@ public static void LastSavedModel ()
151153
System.Collections.Generic.List<UnityEngine.SceneManagement.Scene> scenes
152154
= new System.Collections.Generic.List<UnityEngine.SceneManagement.Scene> ();
153155

154-
var desiredScene = FbxExporters.EditorTools.ExportSettings.instance.turntableScene;
155-
string desiredSceneName = null;
156-
if (desiredScene) {
157-
desiredSceneName = desiredScene.name;
156+
string desiredSceneName = FbxExporters.EditorTools.ExportSettings.GetTurnTableSceneName ();
157+
if (string.IsNullOrEmpty (desiredSceneName)) {
158+
desiredSceneName = DefaultSceneName;
158159
}
159160

160-
bool foundScene = false;
161161
for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCount; i++) {
162162
UnityEngine.SceneManagement.Scene toAdd = UnityEngine.SceneManagement.SceneManager.GetSceneAt (i);
163163

164164
// skip Untitled scene.
165165
// The Untitled scene cannot be unloaded, if modified, and we don't want to force the user to save it.
166166
if (toAdd.name == "") continue;
167167

168-
if (desiredSceneName != null && toAdd.name == desiredSceneName) {
168+
if (toAdd.name == desiredSceneName) {
169169
scene = toAdd;
170-
foundScene = true;
171170
continue;
172171
}
173172

174-
if (!foundScene && toAdd.name == SceneName)
175-
{
176-
scene = toAdd;
177-
continue;
178-
}
179173
scenes.Add (toAdd);
180174
}
181175

182176
// if turntable scene not added to list of scenes
183-
if (!scene.IsValid ())
177+
if (!scene.IsValid () || !scene.isLoaded)
184178
{
185-
string scenePath = null;
186-
if (desiredScene) {
187-
scenePath = UnityEditor.AssetDatabase.GetAssetPath (desiredScene);
188-
} else {
189-
179+
string scenePath = FbxExporters.EditorTools.ExportSettings.GetTurnTableScenePath ();
180+
if (string.IsNullOrEmpty(scenePath)) {
190181
// and if for some reason the turntable scene is missing create an empty scene
191182
// NOTE: we cannot use NewScene because it will force me to save the modified Untitled scene
192183
if (!System.IO.File.Exists (GetSceneFilePath ())) {

0 commit comments

Comments
 (0)