Skip to content

Commit 5ab2d63

Browse files
committed
use scene we specified in Exporter settings
if we find it, else default to what we had
1 parent 28e5489 commit 5ab2d63

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

Assets/FbxExporters/Editor/ReviewLastSavedModel.cs

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,27 @@ public static void LastSavedModel ()
135135
System.Collections.Generic.List<UnityEngine.SceneManagement.Scene> scenes
136136
= new System.Collections.Generic.List<UnityEngine.SceneManagement.Scene> ();
137137

138+
var desiredScene = FbxExporters.EditorTools.ExportSettings.instance.turntableScene;
139+
string desiredSceneName = null;
140+
if (desiredScene) {
141+
desiredSceneName = desiredScene.name;
142+
}
143+
144+
bool foundScene = false;
138145
for (int i = 0; i < UnityEngine.SceneManagement.SceneManager.sceneCount; i++) {
139146
UnityEngine.SceneManagement.Scene toAdd = UnityEngine.SceneManagement.SceneManager.GetSceneAt (i);
140147

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

145-
if (toAdd.name == SceneName)
152+
if (desiredSceneName != null && toAdd.name == desiredSceneName) {
153+
scene = toAdd;
154+
foundScene = true;
155+
continue;
156+
}
157+
158+
if (!foundScene && toAdd.name == SceneName)
146159
{
147160
scene = toAdd;
148161
continue;
@@ -153,17 +166,24 @@ public static void LastSavedModel ()
153166
// if turntable scene not added to list of scenes
154167
if (!scene.IsValid ())
155168
{
156-
// and if for some reason the turntable scene is missing create an empty scene
157-
// NOTE: we cannot use NewScene because it will force me to save the modified Untitled scene
158-
if (!System.IO.File.Exists(GetSceneFilePath ()))
159-
{
160-
var writer = System.IO.File.CreateText (GetSceneFilePath ());
161-
writer.WriteLine ("%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:");
162-
writer.Close ();
163-
UnityEditor.AssetDatabase.Refresh ();
169+
string scenePath = null;
170+
if (desiredScene) {
171+
scenePath = UnityEditor.AssetDatabase.GetAssetPath (desiredScene);
172+
Debug.LogWarning (scenePath);
173+
} else {
174+
175+
// and if for some reason the turntable scene is missing create an empty scene
176+
// NOTE: we cannot use NewScene because it will force me to save the modified Untitled scene
177+
if (!System.IO.File.Exists (GetSceneFilePath ())) {
178+
var writer = System.IO.File.CreateText (GetSceneFilePath ());
179+
writer.WriteLine ("%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:");
180+
writer.Close ();
181+
UnityEditor.AssetDatabase.Refresh ();
182+
}
183+
scenePath = GetSceneFilePath ();
164184
}
165185

166-
scene = UnityEditor.SceneManagement.EditorSceneManager.OpenScene (GetSceneFilePath (), UnityEditor.SceneManagement.OpenSceneMode.Additive);
186+
scene = UnityEditor.SceneManagement.EditorSceneManager.OpenScene (scenePath, UnityEditor.SceneManagement.OpenSceneMode.Additive);
167187
}
168188

169189
// save unmodified scenes (but not the untitled or turntable scene)

0 commit comments

Comments
 (0)