1
+ // ***********************************************************************
2
+ // Copyright (c) 2017 Unity Technologies. All rights reserved.
3
+ //
4
+ // Licensed under the ##LICENSENAME##.
5
+ // See LICENSE.md file in the project root for full license information.
6
+ // ***********************************************************************
1
7
2
8
using UnityEngine ;
3
9
@@ -10,7 +16,7 @@ class TurnTable
10
16
const string MenuItemName = "FbxExporters/Turntable Review/Autoload Last Saved Prefab" ;
11
17
12
18
const string ScenesPath = "Assets" ;
13
- const string SceneName = "FbxExporters_TurnTableReview" ;
19
+ static string SceneName = "FbxExporters_TurnTableReview" ;
14
20
15
21
public const string TempSavePath = "_safe_to_delete" ;
16
22
@@ -82,12 +88,18 @@ private static Object LoadModel (string fbxFileName)
82
88
if ( unityMainAsset ) {
83
89
modelGO = UnityEditor . PrefabUtility . InstantiatePrefab ( unityMainAsset ) as GameObject ;
84
90
85
- GameObject turntableGO = GameObject . Find ( "TurnTable" ) ;
91
+ var turnTableBase = GameObject . FindObjectOfType < FbxTurnTableBase > ( ) ;
92
+ GameObject turntableGO = null ;
93
+ if ( turnTableBase != null ) {
94
+ turntableGO = turnTableBase . gameObject ;
95
+ }
96
+
86
97
if ( turntableGO != null ) {
87
98
modelGO . transform . parent = turntableGO . transform ;
88
- turntableGO . AddComponent < RotateModel > ( ) ;
89
99
} else {
90
- modelGO . AddComponent < RotateModel > ( ) ;
100
+ if ( ! modelGO . GetComponent < RotateModel > ( ) ) {
101
+ modelGO . AddComponent < RotateModel > ( ) ;
102
+ }
91
103
}
92
104
}
93
105
@@ -173,7 +185,6 @@ public static void LastSavedModel ()
173
185
string scenePath = null ;
174
186
if ( desiredScene ) {
175
187
scenePath = UnityEditor . AssetDatabase . GetAssetPath ( desiredScene ) ;
176
- Debug . LogWarning ( scenePath ) ;
177
188
} else {
178
189
179
190
// and if for some reason the turntable scene is missing create an empty scene
@@ -190,6 +201,8 @@ public static void LastSavedModel ()
190
201
scene = UnityEditor . SceneManagement . EditorSceneManager . OpenScene ( scenePath , UnityEditor . SceneManagement . OpenSceneMode . Additive ) ;
191
202
}
192
203
204
+ SceneName = scene . name ;
205
+
193
206
// save unmodified scenes (but not the untitled or turntable scene)
194
207
if ( UnityEditor . SceneManagement . EditorSceneManager . SaveModifiedScenesIfUserWantsTo ( scenes . ToArray ( ) ) )
195
208
{
0 commit comments