@@ -24,10 +24,6 @@ public static void OnMenu ()
24
24
LastSavedModel ( ) ;
25
25
}
26
26
27
- static TurnTable ( ) {
28
- SubscribeToEvents ( ) ;
29
- }
30
-
31
27
private static System . IO . FileInfo GetLastSavedFile ( string directoryPath , string ext = ".fbx" )
32
28
{
33
29
System . IO . DirectoryInfo directoryInfo = new System . IO . DirectoryInfo ( directoryPath ) ;
@@ -91,8 +87,11 @@ private static Object LoadModel (string fbxFileName)
91
87
if ( turntableGO != null ) {
92
88
modelGO . transform . parent = turntableGO . transform ;
93
89
turntableGO . AddComponent < RotateModel > ( ) ;
90
+
91
+ UnityEditor . Selection . objects = new GameObject [ ] { turntableGO } ;
94
92
} else {
95
93
modelGO . AddComponent < RotateModel > ( ) ;
94
+ UnityEditor . Selection . objects = new GameObject [ ] { modelGO } ;
96
95
}
97
96
}
98
97
@@ -219,11 +218,10 @@ public static void LastSavedModel ()
219
218
lightComp . shadows = LightShadows . Soft ;
220
219
}
221
220
222
- // maximize game window and start playing
221
+ // maximize game window
223
222
var gameWindow = GetMainGameView ( ) ;
224
223
if ( gameWindow ) {
225
224
gameWindow . maximized = true ;
226
- UnityEditor . EditorApplication . isPlaying = true ;
227
225
} else {
228
226
Debug . LogWarning ( "Failed to access Game Window, please restart Unity to try again." ) ;
229
227
}
@@ -248,9 +246,6 @@ private static void SubscribeToEvents ()
248
246
// ensure we only subscribe once
249
247
UnityEditor . EditorApplication . hierarchyWindowChanged -= UpdateLastSavedModel ;
250
248
UnityEditor . EditorApplication . hierarchyWindowChanged += UpdateLastSavedModel ;
251
-
252
- UnityEditor . EditorApplication . playmodeStateChanged -= OnPlay ;
253
- UnityEditor . EditorApplication . playmodeStateChanged += OnPlay ;
254
249
}
255
250
256
251
private static void UnsubscribeFromEvents ( )
@@ -261,7 +256,6 @@ private static void UnsubscribeFromEvents ()
261
256
LastFilePath = null ;
262
257
263
258
UnityEditor . EditorApplication . hierarchyWindowChanged -= UpdateLastSavedModel ;
264
- UnityEditor . EditorApplication . playmodeStateChanged -= OnPlay ;
265
259
}
266
260
267
261
private static bool AutoUpdateEnabled ( )
@@ -278,23 +272,6 @@ private static void UpdateLastSavedModel ()
278
272
279
273
LoadLastSavedModel ( ) ;
280
274
}
281
-
282
- private static void OnPlay ( )
283
- {
284
- if ( ! AutoUpdateEnabled ( ) ) {
285
- UnsubscribeFromEvents ( ) ;
286
- return ;
287
- }
288
-
289
- // Right before we enter playmode, unload the last saved model if there is one.
290
- // Unsubscribe from hierarchy window changed event so that unloading the model doesn't
291
- // trigger a new one to be added right before playing.
292
- if ( UnityEditor . EditorApplication . isPlayingOrWillChangePlaymode && ! UnityEditor . EditorApplication . isPlaying ) {
293
- UnityEditor . EditorApplication . hierarchyWindowChanged -= UpdateLastSavedModel ;
294
- UnloadModel ( LastModel ) ;
295
- LastModel = null ;
296
- }
297
- }
298
275
}
299
276
}
300
277
}
0 commit comments