Exemple #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();
    }
Exemple #2
0
    void OnGUI()
    {
        // The actual window code goes here
        skeletonScript        = EditorGUILayout.ObjectField("Skeleton Script", skeletonScript, typeof(SkeletonScripts.SkeletonScript), false) as SkeletonScripts.SkeletonScript;
        skeletonScriptReplace = EditorGUILayout.ObjectField("Skeleton Script Replace", skeletonScriptReplace, typeof(SkeletonScripts.SkeletonScriptReplace), false) as SkeletonScripts.SkeletonScriptReplace;
        if (skeletonScript != null)
        {
            GUI.enabled = false;
            path        = SkeletonScripts.Core.GetProjectDirectory();
            if (path == null)
            {
                path = "";
            }
            EditorGUILayout.TextField(new GUIContent("Directory", "Select a file in the \"Project\" window to set Directory"), path);
            GUI.enabled = true;
            nameOfFile  = EditorGUILayout.TextField("Name", nameOfFile);
            //if (path != null && path[path.Length - 1] == '\\') path.Remove(path.Length - 1);
            //path += "\\";
            previewPath = path + "/" + nameOfFile + skeletonScript.extention;
            if (path != null && nameOfFile != null && !File.Exists(previewPath))
            {
                displayPreview = EditorGUILayout.ToggleLeft("Display Preview", displayPreview);
                error          = !SkeletonScripts.Core.PathValidCheck(previewPath);
                if (!error)
                {
                    if (GUILayout.Button("Create Skeleton Script"))
                    {
                        SkeletonScripts.Core.CreateFile(nameOfFile, skeletonScript.extention, skeletonScript.lines, skeletonScriptReplace.settings);
                        AssetDatabase.Refresh();
                    }
                }
                else
                {
                    GUI.enabled = false;
                    GUILayout.Button("Can't save because of invalid path or name");
                    GUI.enabled = true;
                }

                if (displayPreview)
                {
                    if (GUILayout.Button("Refresh Preview"))
                    {
                        previewContent = SkeletonScripts.Core.GetPreview(skeletonScript.lines, skeletonScriptReplace.settings, nameOfFile);
                        previewPath    = path + "\\" + nameOfFile + skeletonScript.extention;
                    }
                    GUI.enabled = false;
                    EditorGUILayout.LabelField(new GUIContent(previewPath, "Where the Script will save to"));
                    EditorGUILayout.TextArea(previewContent, GUILayout.Height(position.height - 30));
                    GUI.enabled = true;
                }
            }
        }
    }