Ejemplo n.º 1
0
        public static void Backup(Action <MonoScript> onCreateScript)
        {
            if (_Instance == null)
            {
                _Instance = ScriptableObject.CreateInstance <AddButtonScript_EditorWindow>();
            }
            _Instance._CreateScriptDelegate = onCreateScript;

            if (AddButtonScript_EditorWindow_RuntimeBackup.Instance.addAsset)
            {
                var script = AssetDatabase.LoadAssetAtPath <MonoScript>(AddButtonScript_EditorWindow_RuntimeBackup.Instance.scriptPath);
                if (script.GetClass() == null)
                {
                    return;
                }

                string[] assetGUIDS = AssetDatabase.FindAssets("l:ABCD");

                for (int i = 0; i < assetGUIDS.Length; i++)
                {
                    string path = AssetDatabase.GUIDToAssetPath(assetGUIDS[i]);
                    path = System.IO.Path.GetFileNameWithoutExtension(path);
                }
                AssetInfo info = new AssetInfo {
                    AssetPath = ""
                };
                _Instance._CreateScriptDelegate(script);
                AddButtonScript_EditorWindow_RuntimeBackup.Instance.Reset();
            }
        }
Ejemplo n.º 2
0
        private void DrawModules()
        {
            EditorGUILayout.BeginVertical(EditorStyles.helpBox);

            GUIStyle st = new GUIStyle(EditorStyles.miniButton);

            st.fontStyle = FontStyle.Bold;
            st.fontSize  = EditorStyles.boldLabel.fontSize;


            SerializedProperty showStateModule = serializedObject.FindProperty("_ShowStateModules");

            // EditorGUILayout.LabelField("State Modules", st);
            showStateModule.boolValue = GUILayout.Toggle(showStateModule.boolValue, new GUIContent("State Modules"), st);
            serializedObject.ApplyModifiedProperties();

            if (showStateModule.boolValue)
            {
                EditorGUILayout.Space();

                bool draw = true;
                SerializedProperty modules = serializedObject.FindProperty("StateModules");
                for (int i = 0, c = modules.arraySize; i < c; ++i)
                {
                    Object m = modules.GetArrayElementAtIndex(i).objectReferenceValue;
                    if (m == null)
                    {
                        Target.RemoveStateModule(i);
                        EditorGUIUtility.ExitGUI();
                        return;
                    }
                    else
                    {
                        draw &= DrawModule(Editor.CreateEditor(m), i);
                    }
                }

                if (draw && !Application.isPlaying)
                {
                    EditorGUILayout.Space();
                    AddButtonScript_EditorWindow.Show(CreateScriptInstance, AddButtonScript_EditorWindow.CanAddScriptOfType <FSMStateModule>, "", "Add State Module");
                }
            }

            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 3
0
        public static void Show(Action <MonoScript> onCreateScript, Func <MonoScript, bool> onFilerScript, string templatePath, string buttonText = "Add ...")
        {
            if (_Instance == null)
            {
                _Instance = ScriptableObject.CreateInstance <AddButtonScript_EditorWindow>();
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUIStyle style = new GUIStyle(GUI.skin.button);

            style.fontSize    = 12;
            style.fixedWidth  = 230;
            style.fixedHeight = 23;

            var rect = GUILayoutUtility.GetLastRect();

            //var hasAssetToAdd = HasAssetToAdd();
            //EditorGUI.BeginDisabledGroup(hasAssetToAdd);
            if (GUILayout.Button(buttonText, style))
            {
                rect.y    += 26f;
                rect.x    += rect.width;
                rect.width = style.fixedWidth;
                _Instance.Init(rect, onCreateScript, onFilerScript, templatePath);
                _Instance.Repaint();
            }
            //EditorGUI.EndDisabledGroup();
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            //if (hasAssetToAdd)
            //{
            //  //  Backup(onCreateScript);
            //}
        }