Unity游戏编程定制编辑器(二)

来源:互联网 发布:java项目经理必备技能 编辑:程序博客网 时间:2024/06/05 16:00

扩展编辑器的颜色


1 通过GUIStyle的方式

2 通过GUI来改变

    private void DrawTestColor()    {        GUILayout.Label("Title: Color");        GUILayout.Space(4);        // by style        GUIStyle myStyle;        myStyle = new GUIStyle(GUI.skin.label);        myStyle.normal.textColor = Color.red;        myStyle.fontSize = 14;        GUILayout.Label("by GUIStyle", myStyle);        myStyle = new GUIStyle(GUI.skin.textField);        myStyle.normal.background = null;        myStyle.fontSize = 13;        testIntColor = EditorGUILayout.IntField("IntField test", testIntColor, myStyle);        // BY gui        Color saveContent = GUI.contentColor;        Color saveBk = GUI.backgroundColor;               GUI.contentColor = Color.blue;        GUI.backgroundColor = Color.red;        GUILayout.Label("by GUI");        GUI.contentColor = saveContent;                     testIntColor = EditorGUILayout.IntField("IntField test", testIntColor);        GUI.backgroundColor = Color.green;        if (GUILayout.Button("按钮"))        {        }        GUI.backgroundColor = saveBk;    }

0 0