Пример #1
0
        public override void    OnInspectorGUI()
        {
            if (this.isNull == true)
            {
                EditorGUILayout.HelpBox("The associated script can not be loaded.\nPlease fix any compile errors\nand assign a valid script.", MessageType.Warning);

                if (this.isPrefab == true)
                {
                    if (GUILayout.Button("Recover Missing Component") == true)
                    {
                        NGMissingScriptRecoveryWindow instance = EditorWindow.GetWindow <NGMissingScriptRecoveryWindow>(true, NGMissingScriptRecoveryWindow.NormalTitle);

                        if (instance.IsRecovering == false)
                        {
                            instance.Diagnose(Selection.activeGameObject);
                            instance.tab = NGMissingScriptRecoveryWindow.Tab.Selection;
                            instance.Show();
                        }
                        else
                        {
                            EditorUtility.DisplayDialog(NGMissingScriptRecoveryWindow.NormalTitle, "A recovery process is still running.", "OK");
                        }
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox(NGMissingScriptRecoveryWindow.NormalTitle + " can only recover from prefabs.\nCreate a prefab of your broken asset and recover from it.", MessageType.Warning);
                }
            }
            else
            {
                base.OnInspectorGUI();
            }
        }
Пример #2
0
        private static void     Diagnose(MenuCommand command)
        {
            // We assume that the context menu is opened from the active GameObject.
            PrefabType prefabType = PrefabUtility.GetPrefabType(Selection.activeGameObject);
            Object     prefab     = null;

            if (prefabType == PrefabType.Prefab)
            {
                prefab = Selection.activeGameObject;
            }
            else if (prefabType == PrefabType.PrefabInstance)
            {
                prefab = PrefabUtility.GetPrefabParent(Selection.activeGameObject);
            }
            else if (prefabType == PrefabType.DisconnectedPrefabInstance)
            {
                prefab = PrefabUtility.GetPrefabParent(Selection.activeGameObject);
            }

            if (prefab == null)
            {
                EditorUtility.DisplayDialog(NGMissingScriptRecoveryWindow.NormalTitle, "Recover a missing script is only possible on prefab.\n\nYou may temporary create a prefab, recover and then destroy the prefab.", "OK");
                return;
            }

            NGMissingScriptRecoveryWindow instance = EditorWindow.GetWindow <NGMissingScriptRecoveryWindow>(true, NGMissingScriptRecoveryWindow.ShortTitle);

            if (instance.isRecovering == false)
            {
                instance.Diagnose(Selection.activeGameObject);
                instance.tab = Tab.Selection;
                instance.Show();
            }
            else
            {
                EditorUtility.DisplayDialog(NGMissingScriptRecoveryWindow.NormalTitle, "A recovery process is still running.", "OK");
            }
        }