[Editor] EditorGUI Foldout

Unity3D 2013. 9. 1. 00:44
반응형

http://docs.unity3d.com/Documentation/ScriptReference/EditorGUI.Foldout.html







using UnityEngine;
using System.Collections;
using UnityEditor;

public class TestEditor : EditorWindow {

    private bool _showPosition = true;
    private string _status = "test";

    [MenuItem("Test/AnimationChecker")]
    static void Init(){
        EditorWindow window = EditorWindow.GetWindow(typeof(TestEditor));
//        window.position = new Rect(0, 0, 150, 60);
        window.Show();
    }

    void OnGUI(){
        this._showPosition = EditorGUI.Foldout(new Rect(3,3,this.position.width-6, 15), 
                                               this._showPosition, this._status);

        if (this._showPosition)

            if( Selection.activeTransform){

                
                Selection.activeTransform.position 
                    = EditorGUI.Vector3Field(new Rect(3, 25, position.width-6, 40),
                                         "Position", 
                                         Selection.activeTransform.position);

                this._status = Selection.activeTransform.name;
            }
            


        if( !Selection.activeTransform) {
            this._status = "Select a GameObject";
            this._showPosition = false;
        }


        GUILayout.BeginArea(new Rect(0, 100, position.width, 100));
        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField(this._showPosition.ToString());
        EditorGUILayout.LabelField(Selection.activeTransform.ToString());
        EditorGUILayout.EndVertical();
        GUILayout.EndArea();


    }//OnGUI

    void OnInspectorUpdate(){
        this.Repaint();
    }
}




반응형
: