美文网首页
UnityEditor 常用组件

UnityEditor 常用组件

作者: 串串香 | 来源:发表于2017-10-17 17:46 被阅读0次
    文本
        void OnGUI()
        {
            GUILayout.Label("文本", EditorStyles.boldLabel);
        }
    
    Paste_Image.png
    文本框
        string myString = "文本框123";
        void OnGUI()
        {
            myString = EditorGUILayout.TextField("文本框:", myString);
        }
    
    Paste_Image.png
    自定义字体
        void OnGUI()
        {
            GUIStyle fontStyle = new GUIStyle();
            fontStyle.normal.background = null;    //设置背景填充  
            fontStyle.normal.textColor = Color.red;   //设置字体颜色  
            fontStyle.fontStyle = FontStyle.BoldAndItalic;      // 字体加粗倾斜
            fontStyle.fontSize = 18;       //字体大小  
            GUILayout.Label("自定义字体", fontStyle);     
        }
    
    Paste_Image.png
    区域输入框
        void OnGUI()
        {
            GUILayout.Label ("留言簿:");
            areaText = GUILayout.TextArea(areaText, GUILayout.Height(40)); 
        }
    
    Paste_Image.png
    密码框
        string password;
        void OnGUI()
        {
            password = EditorGUILayout.PasswordField ("密码", password);
        }
    
    Paste_Image.png
    枚举弹出菜单
        SystemLanguage language;
        void OnGUI()
        {
            language = (SystemLanguage)EditorGUILayout.EnumPopup("语言:", language);//枚举弹出菜单
        }
    
    Paste_Image.png
    开关
        bool test;
        void OnGUI()
        {
            test = EditorGUILayout.Toggle("开关:", test);
        }
    
    Paste_Image.png
    页签
        int toolbar;
        string[] texts = { "A", "B", "C" };
        void OnGUI()
        {
            toolbar = GUILayout.Toolbar(toolbar,texts);
            switch (toolbar)
            {
            case 0:
                GUILayout.Label("a");
                GUILayout.Label("aa");
                GUILayout.Label("aaa");
                GUILayout.Label("aaaa");
                GUILayout.Label("aaaaa");
                GUILayout.Label("aaaaaa");
                break;
            case 1:
                GUILayout.Label("b");
                GUILayout.Label("bb");
                GUILayout.Label("bbb");
                GUILayout.Label("bbbb");
                GUILayout.Label("bbbbb");
                GUILayout.Label("bbbbbb");
                break;
            case 2:
                GUILayout.Label("c");
                GUILayout.Label("cc");
                GUILayout.Label("ccc");
                GUILayout.Label("cccc");
                GUILayout.Label("ccccc");
                GUILayout.Label("cccccc");
                break;
            }
        }
    
    Paste_Image.png
    滑动条
        float slider = 0;
        void OnGUI()
        {
            slider = EditorGUILayout.Slider(slider, 1, 10);
        }
    
    Paste_Image.png
    设置Tag
        private string tagStr;
        void OnGUI()
        {
            tagStr = EditorGUILayout.TagField("Tag:", tagStr,GUILayout.Width(250));
        }
    
    Paste_Image.png
    通知提示
        private string notification = "ShowNotification";
        void OnGUI()
        {
            notification = EditorGUILayout.TextField (notification);
            this.ShowNotification (new GUIContent (notification));
        }
    
    Paste_Image.png

    相关文章

      网友评论

          本文标题:UnityEditor 常用组件

          本文链接:https://www.haomeiwen.com/subject/xgnduxtx.html