EditorWindow创建工具栏编辑栏编辑物体颜色

public class cButton : EditorWindow
{
[MenuItem(“CREiPad/按钮/添加按钮 _#b”, false, 7)]
static void AddButtonwind()
{
Rect wr = new Rect(0, 0, 500, 500);
cButton window = (cButton)EditorWindow.GetWindowWithRect(typeof(cButton), wr, true, “添加按钮”);
window.Show();
}
//字体颜色
private Color textColor=Color.white;
void OnGUI()
{
textColor = EditorGUILayout.ColorField(“字体颜色”, textColor);
ChangeColor();
if (GUILayout.Button(“确定”))
{
GameObject g = Addbutton(page);
Transform child = g.transform.GetChild(0);
child.GetComponent ().color = textColor;
this.Close();
}
}

///
/// 改变按钮颜色
///
public void ChangeColor()
{
if (Selection.activeGameObject)
{
foreach (GameObject t in Selection.gameObjects)
{
Renderer rend = t.GetComponent();
if (rend!=null)
{
rend.sharedMaterial.color = matColor;
}
}
}
}
}

猜你喜欢

转载自blog.csdn.net/qq_42987283/article/details/83901211