示例#1
0
            public static void CreateUIBase()
            {
                CreateOriginIfNull();
                CopyAsset.CopyNewAsset(newScriptName, originScriptPathWithNameSpace);


                EditorPrefs.SetBool(key, true);
            }
示例#2
0
        public override void OnInspectorGUI()
        {
            if (_scriptCreater == null)
            {
                _scriptCreater = this.target as ScriptCreater;
            }
            _scriptCreater = this.target as ScriptCreater;

            this.Space(10)
            .ETextField("Script Name", ref _scriptCreater.ScriptName)
            .Pan(() => {
                if (!_scriptCreater.ScriptName.IsLegalFieldName())
                {
                    _scriptCreater.ScriptName = _scriptCreater.name.Replace(" ", "").Replace("(", "").Replace(")", "");
                }
            })
            .Label("Description")
            .TextArea(ref _scriptCreater.description, GUILayout.Height(40))
            .Space(10)
            .DrawHorizontal(() => {
                GUILayout.Label(new GUIContent("Create Path:", "Drag Floder To Box"));
                Rect rect = EditorGUILayout.GetControlRect();
                rect.DrawOutLine(2, Color.black);
                EditorGUI.LabelField(rect, _scriptCreater.CreatePath);
                if (!rect.Contains(Event.current.mousePosition))
                {
                    return;
                }
                var info = DragAndDropUtil.Drag(Event.current, rect);
                if (info.paths.Length > 0 && info.Finsh && info.EnterArera && info.paths[0].IsDirectory())
                {
                    _scriptCreater.CreatePath = info.paths[0];
                }
            })
            .Space(10)
            .Toggle("Create Prefab", ref _scriptCreater.isCreatePrefab)
            .Pan(() => {
                if (_scriptCreater.isCreatePrefab)
                {
                    this.ETextField("Prefab Name", ref _scriptCreater.prefabName);
                    this.DrawHorizontal(() =>
                    {
                        GUILayout.Label(new GUIContent("Prefab Path:", "Drag Floder To Box"));
                        Rect rect = EditorGUILayout.GetControlRect();
                        rect.DrawOutLine(2, Color.black);
                        EditorGUI.LabelField(rect, _scriptCreater.prefabDirectory);
                        if (!rect.Contains(Event.current.mousePosition))
                        {
                            return;
                        }
                        var info = DragAndDropUtil.Drag(Event.current, rect);
                        if (info.paths.Length > 0 && info.Finsh && info.EnterArera && info.paths[0].IsDirectory())
                        {
                            _scriptCreater.prefabDirectory = info.paths[0];
                        }
                    });
                }
            })
            .Space(10)
            .DrawHorizontal(() => {
                if (GUILayout.Button("Build", GUILayout.Height(25)))
                {
                    if (BuildCheck())
                    {
                        Selection.objects = new Object[] { AssetDatabase.LoadAssetAtPath <Object>(_scriptCreater.CreatePath) };
                        CopyAsset.CopyNewAsset(_scriptCreater.ScriptName.Append(".cs"), originScriptPath);
                    }
                }
                if (GUILayout.Button("Remove", GUILayout.Height(25)))
                {
                    _scriptCreater.GetComponentsInChildren <ScriptMark>(true).ToList().ForEach((sm) => {
                        DestroyImmediate(sm);
                    });
                    DestroyImmediate(_scriptCreater);
                }
            });
            serializedObject.Update();
        }