private void OnGUI()
        {
            _typeToReplace     = SPEditorGUILayout.TypeDropDown(EditorHelper.TempContent("Type to Replace"), typeof(MonoBehaviour), _typeToReplace);
            _typeToReplaceWith = SPEditorGUILayout.TypeDropDown(EditorHelper.TempContent("New Type"), typeof(MonoBehaviour), _typeToReplaceWith);

            if (GUILayout.Button("Scan"))
            {
                this.DoScan();
            }
        }
Esempio n. 2
0
        private void OnGUI()
        {
            //draw header
            GUILayout.Space(3);
            EditorGUI.BeginChangeCheck();
            _mode = SPEditorGUILayout.SelectionTabs(_mode, _modes, 2);
            if (EditorGUI.EndChangeCheck())
            {
                _prefabResults.Clear();
                _sceneResults.Clear();
                _forceRefresh = true;
            }
            GUILayout.Space(3);

            switch (_mode)
            {
            case 0:
                EditorGUI.BeginChangeCheck();
                _targetScript = SPEditorGUILayout.TypeDropDown(GUIContent.none, typeof(Component), _targetScript, false, false);
                if (EditorGUI.EndChangeCheck() || _forceRefresh)
                {
                    this.FillBySearchForComponentUsage(false);
                }
                if (_prefabResults.Count == 0)
                {
                    var msgStyle = new GUIStyle(GUI.skin.label);
                    msgStyle.alignment = TextAnchor.MiddleCenter;
                    msgStyle.fontStyle = FontStyle.Bold;
                    string msg = (_targetScript == null) ? "Choose a script file." : "No prefabs use component " + _targetScript.FullName;
                    EditorGUI.LabelField(new Rect(0f, this.position.height / 2f, this.position.width, EditorGUIUtility.singleLineHeight), msg, msgStyle);
                }
                else
                {
                    this.DoDrawPrefabList();
                }
                break;

            case 1:
                EditorGUI.BeginChangeCheck();
                _targetScript = SPEditorGUILayout.TypeDropDown(GUIContent.none, typeof(Component), _targetScript, false, false);
                if (EditorGUI.EndChangeCheck() || _forceRefresh)
                {
                    this.FillBySearchForComponentUsage(true);
                }
                if (_prefabResults.Count == 0)
                {
                    var msgStyle = new GUIStyle(GUI.skin.label);
                    msgStyle.alignment = TextAnchor.MiddleCenter;
                    msgStyle.fontStyle = FontStyle.Bold;
                    string msg = (_targetScript == null) ? "Choose a script file." : "No scene objects use component " + _targetScript.FullName;
                    EditorGUI.LabelField(new Rect(0f, this.position.height / 2f, this.position.width, EditorGUIUtility.singleLineHeight), msg, msgStyle);
                }
                else
                {
                    this.DoDrawSceneList();
                }
                break;

            case 2:
                if (GUILayout.Button("Search!"))
                {
                    this.FillBySearchForMissingComponents(false);
                }
                if (_prefabResults.Count == 0)
                {
                    var msgStyle = new GUIStyle(GUI.skin.label);
                    msgStyle.alignment = TextAnchor.MiddleCenter;
                    msgStyle.fontStyle = FontStyle.Bold;
                    EditorGUI.LabelField(new Rect(0f, this.position.height / 2f, this.position.width, EditorGUIUtility.singleLineHeight * 2f), "No prefabs are missing any script references!\nClick Search to check again.", msgStyle);
                }
                else
                {
                    this.DoDrawPrefabList();
                }
                break;

            case 3:
                if (GUILayout.Button("Search!"))
                {
                    this.FillBySearchForMissingComponents(true);
                }
                if (_prefabResults.Count == 0)
                {
                    var msgStyle = new GUIStyle(GUI.skin.label);
                    msgStyle.alignment = TextAnchor.MiddleCenter;
                    msgStyle.fontStyle = FontStyle.Bold;
                    EditorGUI.LabelField(new Rect(0f, this.position.height / 2f, this.position.width, EditorGUIUtility.singleLineHeight * 2f), "No scene objects are missing any script references!\nClick Search to check again.", msgStyle);
                }
                else
                {
                    this.DoDrawSceneList();
                }
                break;
            }

            _forceRefresh = false;
        }