Exemplo n.º 1
0
    // Draw the property inside the given rect
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        SkeletonScripts.SkeletonScript skeletonScript = (serializedObject.targetObject as SkeletonScripts.SkeletonScript);
        Undo.RecordObject(skeletonScript, "Skeleton script change properties");
        using (new GUILayout.VerticalScope("box"))
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("rawFile"), new GUIContent("Raw File", "this gets the extention and lines from a file"));
            if (skeletonScript.rawFile == null)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button(GUI.enabled ? "Update Info From File" : "Missing Raw File to Update From"))
            {
                skeletonScript.UpdateInfo();
                EditorUtility.SetDirty(skeletonScript);
            }
        }
        GUI.enabled = true;
        EditorGUILayout.PropertyField(serializedObject.FindProperty("extention"), new GUIContent("Extention", "the extention the new files will be (like .cs or .cg)"));
        //
        scroll = EditorGUILayout.BeginScrollView(scroll);
        lines  = EditorGUILayout.TextArea(skeletonScript.lines, GUILayout.ExpandHeight(true));
        EditorGUILayout.EndScrollView();

        if (GUILayout.Button("Use in New Script"))
        {
            CreateSkeletonScriptWindow.skeletonScript = skeletonScript;
            CreateSkeletonScriptWindow.ShowWindow();
        }
        serializedObject.ApplyModifiedProperties();
    }
    // Draw the property inside the given rect
    public override void OnInspectorGUI()
    {
        SkeletonScripts.SkeletonScriptReplace skeletonScriptReplace = (serializedObject.targetObject as SkeletonScripts.SkeletonScriptReplace);
        using (new GUILayout.VerticalScope("box"))
        {
            skeletonScriptReplace.settings.enableReplaceWithFileNameList = EditorGUILayout.ToggleLeft("Replace With File Name", skeletonScriptReplace.settings.enableReplaceWithFileNameList);
            if (!skeletonScriptReplace.settings.enableReplaceWithFileNameList)
            {
                GUI.enabled = false;
            }
            EditorGUI.indentLevel++;
            using (new GUILayout.VerticalScope("box"))
            {
                expandFileName = EditorGUILayout.Foldout(expandFileName, new GUIContent(expandFileName ? "Hide" : "Show"));
                if (expandFileName)
                {
                    int count = skeletonScriptReplace.settings.ReplaceWithFileNameList.Count;
                    for (int i = 0; i < count; i++)
                    {
                        skeletonScriptReplace.settings.ReplaceWithFileNameList[i] = EditorGUILayout.DelayedTextField("Find", skeletonScriptReplace.settings.ReplaceWithFileNameList[i]);
                    }
                    if (GUILayout.Button("Add"))
                    {
                        skeletonScriptReplace.settings.ReplaceWithFileNameList.Add("");
                    }
                    if (GUILayout.Button("Remove"))
                    {
                        if (count > 0)
                        {
                            skeletonScriptReplace.settings.ReplaceWithFileNameList.RemoveAt(count - 1);
                        }
                    }
                }
                EditorGUI.indentLevel--;
                GUI.enabled = true;
            }
        }
        using (new GUILayout.VerticalScope("box"))
        {
            skeletonScriptReplace.settings.enableReplaceList = EditorGUILayout.ToggleLeft("Replace With", skeletonScriptReplace.settings.enableReplaceList);
            if (!skeletonScriptReplace.settings.enableReplaceList)
            {
                GUI.enabled = false;
            }
            EditorGUI.indentLevel++;
            using (new GUILayout.VerticalScope("box"))
            {
                expandReplaceWith = EditorGUILayout.Foldout(expandReplaceWith, new GUIContent(expandReplaceWith ? "Hide" : "Show"));
                if (expandReplaceWith)
                {
                    int count = skeletonScriptReplace.settings.ReplaceList.Count;
                    for (int i = 0; i < count; i++)
                    {
                        using (new GUILayout.VerticalScope("box"))
                        {
                            SkeletonScripts.Core.ReplaceSettings.FindAndReplace findAndReplace = skeletonScriptReplace.settings.ReplaceList[i];
                            findAndReplace.Find    = EditorGUILayout.DelayedTextField("Find", findAndReplace.Find);
                            findAndReplace.Replace = EditorGUILayout.DelayedTextField("Replace With", findAndReplace.Replace);
                            skeletonScriptReplace.settings.ReplaceList[i] = findAndReplace;
                        }
                    }
                    //using (var verticalScope = new GUILayout.VerticalScope("box"))
                    {
                        if (GUILayout.Button("Add"))
                        {
                            skeletonScriptReplace.settings.ReplaceList.Add(new SkeletonScripts.Core.ReplaceSettings.FindAndReplace());
                        }
                        if (GUILayout.Button("Remove"))
                        {
                            if (count > 0)
                            {
                                skeletonScriptReplace.settings.ReplaceList.RemoveAt(count - 1);
                            }
                        }
                    }
                }
                EditorGUI.indentLevel--;
                GUI.enabled = true;
            }
        }

        if (GUILayout.Button("Use in new Script"))
        {
            CreateSkeletonScriptWindow.skeletonScriptReplace = skeletonScriptReplace;
            CreateSkeletonScriptWindow.ShowWindow();
        }
    }