ForceReloadInspectors() private method

private ForceReloadInspectors ( ) : void
return void
Example #1
0
        internal static void RevertPrefabAddedGameObject(object userData)
        {
            GameObject obj = (GameObject)userData;

            PrefabUtility.RevertAddedGameObject(obj, InteractionMode.UserAction);
            EditorUtility.ForceReloadInspectors();
        }
Example #2
0
        internal static void RevertPrefabObjectOverride(object userData)
        {
            Object obj = (Object)userData;

            PrefabUtility.RevertObjectOverride(obj, InteractionMode.UserAction);
            EditorUtility.ForceReloadInspectors();
        }
Example #3
0
 private static void SetRolloffToTarget(SerializedProperty property, Object target)
 {
     property.SetToValueOfTarget(target);
     property.serializedObject.FindProperty("rolloffMode").SetToValueOfTarget(target);
     property.serializedObject.ApplyModifiedProperties();
     EditorUtility.ForceReloadInspectors();
 }
Example #4
0
        private void DoButton(GUIContent content, Texture2D selectedIcon, bool labelIcon)
        {
            int controlId = GUIUtility.GetControlID(IconSelector.s_HashIconSelector, FocusType.Keyboard);

            if ((UnityEngine.Object)content.image == (UnityEngine.Object)selectedIcon)
            {
                Rect  position = GUILayoutUtility.topLevel.PeekNext();
                float num      = 2f;
                position.x     -= num;
                position.y     -= num;
                position.width  = (float)selectedIcon.width + 2f * num;
                position.height = (float)selectedIcon.height + 2f * num;
                GUI.Label(position, GUIContent.none, !labelIcon ? IconSelector.m_Styles.selection : IconSelector.m_Styles.selectionLabel);
            }
            if (!EditorGUILayout.IconButton(controlId, content, GUIStyle.none))
            {
                return;
            }
            EditorGUIUtility.SetIconForObject(this.m_TargetObject, this.ConvertSmallIconToLargeIcon((Texture2D)content.image, labelIcon));
            EditorUtility.ForceReloadInspectors();
            AnnotationWindow.IconChanged();
            if (Event.current.clickCount != 2)
            {
                return;
            }
            this.CloseWindow();
        }
Example #5
0
        private void DoButton(GUIContent content, Texture2D selectedIcon, bool labelIcon)
        {
            int controlID = GUIUtility.GetControlID(s_HashIconSelector, FocusType.Keyboard);

            if (content.image == selectedIcon)
            {
                Rect  position = GUILayoutUtility.topLevel.PeekNext();
                float num2     = 2f;
                position.x     -= num2;
                position.y     -= num2;
                position.width  = selectedIcon.width + (2f * num2);
                position.height = selectedIcon.height + (2f * num2);
                GUI.Label(position, GUIContent.none, !labelIcon ? m_Styles.selection : m_Styles.selectionLabel);
            }
            if (EditorGUILayout.IconButton(controlID, content, GUIStyle.none, new GUILayoutOption[0]))
            {
                Texture2D icon = this.ConvertSmallIconToLargeIcon((Texture2D)content.image, labelIcon);
                EditorGUIUtility.SetIconForObject(this.m_TargetObject, icon);
                EditorUtility.ForceReloadInspectors();
                AnnotationWindow.IconChanged();
                if (Event.current.clickCount == 2)
                {
                    this.CloseWindow();
                }
            }
        }
Example #6
0
        internal static void RevertPrefabRemovedComponent(object userData)
        {
            ObjectInstanceAndSourceInfo info = (ObjectInstanceAndSourceInfo)userData;

            PrefabUtility.RevertRemovedComponent((GameObject)info.instanceObject, (Component)info.correspondingObjectInSource, InteractionMode.UserAction);
            EditorUtility.ForceReloadInspectors();
        }
Example #7
0
        internal static void DeleteArrayElement(object userData)
        {
            SerializedProperty serializedProperty = (SerializedProperty)userData;

            serializedProperty.DeleteCommand();
            serializedProperty.serializedObject.ApplyModifiedProperties();
            EditorUtility.ForceReloadInspectors();
        }
Example #8
0
        internal static void SetPrefabOverride(object userData)
        {
            SerializedProperty serializedProperty = (SerializedProperty)userData;

            serializedProperty.prefabOverride = false;
            serializedProperty.serializedObject.ApplyModifiedProperties();
            EditorUtility.ForceReloadInspectors();
        }
Example #9
0
        internal static bool DeleteArrayElement(object userData)
        {
            SerializedProperty property = (SerializedProperty)userData;
            bool result = property.DeleteCommand();

            property.serializedObject.ApplyModifiedProperties();
            EditorUtility.ForceReloadInspectors();
            return(result);
        }
Example #10
0
 internal static void RevertPrefabPropertyOverride(object userData)
 {
     SerializedProperty[] properties = (SerializedProperty[])userData;
     for (int i = 0; i < properties.Length; i++)
     {
         PrefabUtility.RevertPropertyOverride(properties[i], InteractionMode.UserAction);
     }
     EditorUtility.ForceReloadInspectors();
 }
Example #11
0
        internal static void ApplyPrefabObjectOverride(object userData)
        {
            ObjectInstanceAndSourcePathInfo info = (ObjectInstanceAndSourcePathInfo)userData;

            if (!PrefabUtility.PromptAndCheckoutPrefabIfNeeded(info.assetPath, PrefabUtility.SaveVerb.Apply))
            {
                return;
            }
            PrefabUtility.ApplyObjectOverride(info.instanceObject, info.assetPath, InteractionMode.UserAction);
            EditorUtility.ForceReloadInspectors();
        }
Example #12
0
        internal static void ApplyPrefabRemovedComponent(object userData)
        {
            ObjectInstanceAndSourceInfo info = (ObjectInstanceAndSourceInfo)userData;
            string path = AssetDatabase.GetAssetPath(info.correspondingObjectInSource);

            if (!PrefabUtility.PromptAndCheckoutPrefabIfNeeded(path, PrefabUtility.SaveVerb.Apply))
            {
                return;
            }
            PrefabUtility.ApplyRemovedComponent((GameObject)info.instanceObject, (Component)info.correspondingObjectInSource, InteractionMode.UserAction);
            EditorUtility.ForceReloadInspectors();
        }
Example #13
0
 private void DoTopSection(bool anySelected)
 {
     GUI.Label(new Rect(6f, 4f, 110f, 20f), "Select Icon");
     EditorGUI.BeginDisabledGroup(!anySelected);
     if (GUI.Button(new Rect(93f, 6f, 43f, 12f), this.m_NoneButtonContent, IconSelector.m_Styles.noneButton))
     {
         EditorGUIUtility.SetIconForObject(this.m_TargetObject, (Texture2D)null);
         EditorUtility.ForceReloadInspectors();
         AnnotationWindow.IconChanged();
     }
     EditorGUI.EndDisabledGroup();
 }
Example #14
0
        void SetIconForSelectedObjects(Texture2D icon)
        {
            Undo.RecordObjects(m_TargetObjectList, "Set Icon On GameObject");

            foreach (var target in m_TargetObjectList)
            {
                EditorGUIUtility.SetIconForObject(target, icon);
            }
            SetMultipleSelectedIcons();
            EditorUtility.ForceReloadInspectors();
            AnnotationWindow.IconChanged();
        }
Example #15
0
        internal static void ApplyPrefabPropertyOverride(object userData)
        {
            PropertyAndSourcePathInfo info = (PropertyAndSourcePathInfo)userData;

            if (!PrefabUtility.PromptAndCheckoutPrefabIfNeeded(info.assetPath, PrefabUtility.SaveVerb.Apply))
            {
                return;
            }
            for (int i = 0; i < info.properties.Length; i++)
            {
                PrefabUtility.ApplyPropertyOverride(info.properties[i], info.assetPath, InteractionMode.UserAction);
            }
            EditorUtility.ForceReloadInspectors();
        }
Example #16
0
        private void DoTopSection(bool anySelected)
        {
            Rect position = new Rect(6f, 4f, 110f, 20f);

            GUI.Label(position, "Select Icon");
            using (new EditorGUI.DisabledScope(!anySelected))
            {
                Rect rect2 = new Rect(93f, 6f, 43f, 12f);
                if (GUI.Button(rect2, this.m_NoneButtonContent, m_Styles.noneButton))
                {
                    EditorGUIUtility.SetIconForObject(this.m_TargetObject, null);
                    EditorUtility.ForceReloadInspectors();
                    AnnotationWindow.IconChanged();
                }
            }
        }
Example #17
0
        void DoTopSection(bool anySelected)
        {
            Rect selectIconRect = new Rect(6, 4, 110, 20);

            GUI.Label(selectIconRect, "Select Icon");

            // Draw selection background if none is selected
            using (new EditorGUI.DisabledScope(!anySelected))
            {
                Rect noneButtonRect = new Rect(93, 6, 43, 12);
                if (GUI.Button(noneButtonRect, m_NoneButtonContent, m_Styles.noneButton))
                {
                    EditorGUIUtility.SetIconForObject(m_TargetObject, null);
                    EditorUtility.ForceReloadInspectors();
                    AnnotationWindow.IconChanged();
                }
            }
        }
Example #18
0
        void DoButton(GUIContent content, Texture2D selectedIcon, bool labelIcon)
        {
            int controlID = GUIUtility.GetControlID(s_HashIconSelector, FocusType.Keyboard);

            // Draw selection background if this is the selected icon
            if (content.image == selectedIcon)
            {
                // When placing our selection background we assume that icons rendered from top left corner
                Rect  rect = GUILayoutUtility.topLevel.PeekNext();
                float pad  = 2;
                rect.x     -= pad;
                rect.y     -= pad;
                rect.width  = selectedIcon.width + 2 * pad;
                rect.height = selectedIcon.height + 2 * pad;
                GUI.Label(rect, GUIContent.none, labelIcon ? m_Styles.selectionLabel : m_Styles.selection);
            }

            // Do icon
            if (EditorGUILayout.IconButton(controlID, content, GUIStyle.none))
            {
                // Map to new icon
                Texture2D largeIcon = ConvertSmallIconToLargeIcon((Texture2D)content.image, labelIcon);
                Undo.RecordObject(m_TargetObject, "Set Icon On GameObject");
                EditorGUIUtility.SetIconForObject(m_TargetObject, largeIcon);

                // We assume that we are setting icon in an inspector or annotation window (todo: make repaint delegate)
                EditorUtility.ForceReloadInspectors();
                AnnotationWindow.IconChanged();

                // Close on double click
                if (Event.current.clickCount == 2)
                {
                    CloseWindow();
                }
            }
        }
Example #19
0
 internal static void SetToValueOfTarget(SerializedProperty property, UnityEngine.Object target)
 {
     property.SetToValueOfTarget(target);
     property.serializedObject.ApplyModifiedProperties();
     EditorUtility.ForceReloadInspectors();
 }
Example #20
0
 internal static void RevertPrefabPropertyOverride(object userData)
 {
     SerializedProperty[] properties = (SerializedProperty[])userData;
     PrefabUtility.RevertPropertyOverrides(properties, InteractionMode.UserAction);
     EditorUtility.ForceReloadInspectors();
 }
Example #21
0
        // Internal for testing framework
        internal void SaveDirtyPrefabAssets(bool reloadInspectors)
        {
            if (assetTargets == null)
            {
                return;
            }

            if (assetTarget == null)
            {
                return;
            }

            m_DirtyPrefabAssets.Clear();
            foreach (var asset in assetTargets)
            {
                // The asset could have been deleted when this method is called from OnDestroy().
                // E.g delete the selected prefab asset from the Project Browser.
                if (asset == null)
                {
                    continue;
                }

                if (!EditorUtility.IsPersistent(asset))
                {
                    continue;
                }

                if (!(asset is GameObject))
                {
                    continue;
                }

                var rootGameObject = (GameObject)asset;
                if (IsDirty(rootGameObject))
                {
                    string currentGuid    = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(rootGameObject));
                    var    changeTracking = new TrackedAsset()
                    {
                        asset = rootGameObject,
                        guid  = currentGuid,
                        hash  = AssetDatabase.GetSourceAssetFileHash(currentGuid)
                    };
                    m_DirtyPrefabAssets.Add(changeTracking);
                }
            }

            if (m_DirtyPrefabAssets.Count > 0)
            {
                AssetDatabase.StartAssetEditing();
                try
                {
                    foreach (var trackedAsset in m_DirtyPrefabAssets)
                    {
                        bool savedSuccesfully;
                        PrefabUtility.SavePrefabAsset(trackedAsset.asset, out savedSuccesfully);
                        if (!savedSuccesfully)
                        {
                            string title   = L10n.Tr("Saving Failed");
                            string message = L10n.Tr("Check the Console window to get more insight into what needs to be fixed on the Prefab Asset.\n\nYou can open Prefab Mode to fix any issues on child GameObjects");
                            EditorUtility.DisplayDialog(title, message, L10n.Tr("OK"));

                            m_SavingHasFailed = true;
                            break;
                        }
                    }
                }
                finally
                {
                    AssetDatabase.StopAssetEditing();

                    if (reloadInspectors)
                    {
                        foreach (var trackedAsset in m_DirtyPrefabAssets)
                        {
                            if (AssetDatabase.GetSourceAssetFileHash(trackedAsset.guid) != trackedAsset.hash)
                            {
                                // We only call ForceReloadInspectors (and not ForceRebuildInspectors) to ensure local inspector state
                                // is not destroyed, such as a foldout state maintained by an editor (case 1255013).
                                // And we need to reload Prefab asset inspectors in order for the preview to be regenerated since the preview shows
                                // an instantiated Prefab. E.g disable a MeshRenderer on a Prefab Asset and the mesh should be hidden in the preview.
                                EditorUtility.ForceReloadInspectors();
                                break;
                            }
                        }
                    }
                }
            }
        }