Skip to content

Commit ca3fe88

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into UNI-23252-review-autofocus
# Conflicts: # Assets/FbxExporters/Editor/ReviewLastSavedModel.cs
2 parents 763cf4f + a985e10 commit ca3fe88

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Assets/FbxExporters/Editor/FbxPrefabInspector.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@ public class FbxPrefabInspector : UnityEditor.Editor {
88
public override void OnInspectorGUI() {
99
FbxPrefab fbxPrefab = (FbxPrefab)target;
1010

11+
// We can only change these settings when applied to a prefab.
12+
bool isDisabled = AssetDatabase.GetAssetPath(fbxPrefab) == "";
13+
if (isDisabled) {
14+
EditorGUILayout.HelpBox("Please select a prefab. You can't edit an instance in the scene.",
15+
MessageType.Info);
16+
}
17+
EditorGUI.BeginDisabledGroup(isDisabled);
18+
1119
fbxPrefab.SetAutoUpdate(EditorGUILayout.Toggle ("Auto-update:", fbxPrefab.WantsAutoUpdate()));
12-
if (!fbxPrefab.WantsAutoUpdate()) {
20+
if (!isDisabled && !fbxPrefab.WantsAutoUpdate()) {
1321
if (GUILayout.Button("Sync prefab to FBX")) {
1422
fbxPrefab.SyncPrefab();
1523
}
@@ -30,6 +38,8 @@ public override void OnInspectorGUI() {
3038
EditorGUILayout.SelectableLabel(fbxPrefab.GetFbxHistory().ToJson());
3139
GUILayout.EndHorizontal();
3240
#endif
41+
42+
EditorGUI.EndDisabledGroup();
3343
}
3444
}
3545
}

Assets/FbxExporters/Editor/ReviewLastSavedModel.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,30 @@ public static void LastSavedModel ()
210210
lightComp.shadows = LightShadows.Soft;
211211
}
212212

213+
// maximize game window and start playing
214+
var gameWindow = GetMainGameView();
215+
if (gameWindow) {
216+
gameWindow.maximized = true;
217+
UnityEditor.EditorApplication.isPlaying = true;
218+
} else {
219+
Debug.LogWarning ("Failed to access Game Window, please restart Unity to try again.");
220+
}
221+
213222
if (AutoUpdateEnabled ()) {
214223
LoadLastSavedModel ();
215224

216225
SubscribeToEvents ();
217226
}
218227
}
219228

229+
public static UnityEditor.EditorWindow GetMainGameView()
230+
{
231+
System.Reflection.Assembly assembly = typeof(UnityEditor.EditorWindow).Assembly;
232+
System.Type type = assembly.GetType("UnityEditor.GameView");
233+
UnityEditor.EditorWindow gameview = UnityEditor.EditorWindow.GetWindow(type, false, null, true);
234+
return gameview;
235+
}
236+
220237
private static void SubscribeToEvents ()
221238
{
222239
// ensure we only subscribe once

0 commit comments

Comments
 (0)