private void DisplayScenesGUI() { if (_scenes == null) { _scenes = fiEditorUtility.GetAllScenes(); } GUILayout.Label("Quick Scene Loader", EditorStyles.boldLabel); _sceneListScroll = GUILayout.BeginScrollView(_sceneListScroll); fiEditorGUILayout.WithIndent(25, () => { foreach (var scene in _scenes) { float buttonWidth = 50; var rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight); Rect buttonRect, labelRect; SplitRect(rect, buttonWidth, 5, out buttonRect, out labelRect); if (GUI.Button(buttonRect, "Load")) { EditorApplication.OpenScene(scene); SceneObjectSelections = null; } if (EditorApplication.currentScene == scene) { EditorGUI.LabelField(labelRect, "<b>" + scene + "</b>", RichLabel); } else { EditorGUI.LabelField(labelRect, scene); } } }); GUILayout.EndScrollView(); }
private void DisplayScenesGUI() { if (_scenes == null) _scenes = fiEditorUtility.GetAllScenes(); GUILayout.Label("Quick Scene Loader", EditorStyles.boldLabel); _sceneListScroll = GUILayout.BeginScrollView(_sceneListScroll); fiEditorGUILayout.WithIndent(25, () => { foreach (var scene in _scenes) { float buttonWidth = 50; var rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight); Rect buttonRect, labelRect; SplitRect(rect, buttonWidth, 5, out buttonRect, out labelRect); if (GUI.Button(buttonRect, "Load")) { EditorApplication.OpenScene(scene); SceneObjectSelections = null; } if (EditorApplication.currentScene == scene) { EditorGUI.LabelField(labelRect, "<b>" + scene + "</b>", RichLabel); } else { EditorGUI.LabelField(labelRect, scene); } } }); GUILayout.EndScrollView(); }
public void OnGUI() { EnsureResources(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); _disablePopups = GUILayout.Toggle(_disablePopups, "Disable Dialog Boxes"); GUILayout.EndHorizontal(); GUILayout.Label("<b><size=25>About</size></b> If you've decided to change serializers (for example, from Json.NET to Full Serializer), then this utility will assist your migration.", RichLabel); fiEditorGUILayout.Splitter(3); IPropertyEditor editor = PropertyEditor.Get(typeof(TypeSpecifier <BaseSerializer>), null).FirstEditor; GUILayout.Label("Select the <i>current</i> serializer and then the <i>new</i> serializer", RichLabel); fiEditorGUILayout.WithIndent(50, () => { WithTemporaryLabelWidth(120, () => { editor.EditWithGUILayout(new GUIContent("Current Serializer"), _currentSerializer, _metadata.Enter(0)); editor.EditWithGUILayout(new GUIContent("New Serializer"), _newSerializer, _metadata.Enter(1)); }); }); fiEditorGUILayout.Splitter(3); if (_currentSerializer.Type == null || _newSerializer.Type == null) { return; } if (_currentSerializer.Type == _newSerializer.Type) { EditorGUILayout.HelpBox("You cannot migrate to the same serializer", MessageType.Error); return; } _selectedMode = GUILayout.SelectionGrid(_selectedMode, new string[] { "Migrate Active Selection", "Migrate Scene Objects", "Migrate Persistent Objects" }, 3); if (_selectedMode == 0) { GameObject[] toMigrate = DisplaySelection(); if (GUILayout.Button("Run Migration") && CheckAnnotationsPopup()) { BeforeMigrate(); foreach (var obj in toMigrate) { fiSerializerMigrationUtility.MigrateUnityObject(obj, _currentSerializer.Type, _newSerializer.Type); } DisplayPostSerializeMessage(); } } else if (_selectedMode == 1) { DisplayScenesGUI(); if (SceneObjectSelections == null) { SceneObjectSelections = new UnityObjectSelectionGroup(fiSerializerMigrationUtility.GetSceneObjects()); } GUILayout.Label("Scene Objects to Process", EditorStyles.boldLabel); SceneObjectSelections.OnGUI(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Run Migration", GUILayout.ExpandWidth(true)) && CheckAnnotationsPopup()) { BeforeMigrate(); foreach (var obj in SceneObjectSelections.Selected) { fiSerializerMigrationUtility.MigrateUnityObject(obj, _currentSerializer.Type, _newSerializer.Type); } DisplayPostSerializeMessage(); } } else if (_selectedMode == 2) { if (PersistentObjectSelections == null) { PersistentObjectSelections = new UnityObjectSelectionGroup(fiSerializerMigrationUtility.GetPersistentObjects()); } GUILayout.Label("Persistent GameObjects to Process", EditorStyles.boldLabel); PersistentObjectSelections.OnGUI(); if (GUILayout.Button("Run Migration", GUILayout.ExpandWidth(true)) && CheckAnnotationsPopup()) { BeforeMigrate(); foreach (var obj in PersistentObjectSelections.Selected) { fiSerializerMigrationUtility.MigrateUnityObject(obj, _currentSerializer.Type, _newSerializer.Type); } DisplayPostSerializeMessage(); } } }
public void OnGUI() { EnsureResources(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); _disablePopups = GUILayout.Toggle(_disablePopups, "Disable Dialog Boxes"); GUILayout.EndHorizontal(); GUILayout.Label("<b><size=25>About</size></b> If you've decided to change serializers (for example, from Json.NET to Full Serializer), then this utility will assist your migration.", RichLabel); fiEditorGUILayout.Splitter(3); IPropertyEditor editor = PropertyEditor.Get(typeof(TypeSpecifier<BaseSerializer>), null).FirstEditor; GUILayout.Label("Select the <i>current</i> serializer and then the <i>new</i> serializer", RichLabel); fiEditorGUILayout.WithIndent(50, () => { WithTemporaryLabelWidth(120, () => { editor.EditWithGUILayout(new GUIContent("Current Serializer"), _currentSerializer, _metadata.Enter(0)); editor.EditWithGUILayout(new GUIContent("New Serializer"), _newSerializer, _metadata.Enter(1)); }); }); fiEditorGUILayout.Splitter(3); if (_currentSerializer.Type == null || _newSerializer.Type == null) return; if (_currentSerializer.Type == _newSerializer.Type) { EditorGUILayout.HelpBox("You cannot migrate to the same serializer", MessageType.Error); return; } _selectedMode = GUILayout.SelectionGrid(_selectedMode, new string[] { "Migrate Active Selection", "Migrate Scene Objects", "Migrate Persistent Objects" }, 3); if (_selectedMode == 0) { GameObject[] toMigrate = DisplaySelection(); if (GUILayout.Button("Run Migration") && CheckAnnotationsPopup()) { BeforeMigrate(); foreach (var obj in toMigrate) { fiSerializerMigrationUtility.MigrateUnityObject(obj, _currentSerializer.Type, _newSerializer.Type); } DisplayPostSerializeMessage(); } } else if (_selectedMode == 1) { DisplayScenesGUI(); if (SceneObjectSelections == null) { SceneObjectSelections = new UnityObjectSelectionGroup(fiSerializerMigrationUtility.GetSceneObjects()); } GUILayout.Label("Scene Objects to Process", EditorStyles.boldLabel); SceneObjectSelections.OnGUI(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Run Migration", GUILayout.ExpandWidth(true)) && CheckAnnotationsPopup()) { BeforeMigrate(); foreach (var obj in SceneObjectSelections.Selected) { fiSerializerMigrationUtility.MigrateUnityObject(obj, _currentSerializer.Type, _newSerializer.Type); } DisplayPostSerializeMessage(); } } else if (_selectedMode == 2) { if (PersistentObjectSelections == null) { PersistentObjectSelections = new UnityObjectSelectionGroup(fiSerializerMigrationUtility.GetPersistentObjects()); } GUILayout.Label("Persistent GameObjects to Process", EditorStyles.boldLabel); PersistentObjectSelections.OnGUI(); if (GUILayout.Button("Run Migration", GUILayout.ExpandWidth(true)) && CheckAnnotationsPopup()) { BeforeMigrate(); foreach (var obj in PersistentObjectSelections.Selected) { fiSerializerMigrationUtility.MigrateUnityObject(obj, _currentSerializer.Type, _newSerializer.Type); } DisplayPostSerializeMessage(); } } }