标签:style blog http color io os 使用 2014 div
基本方法:
public static bool Button(Rect position, GUIContent content); public static bool Button(Rect position, string text); public static bool Button(Rect position, Texture image); public static bool Button(Rect position, GUIContent content, GUIStyle style); public static bool Button(Rect position, string text, GUIStyle style); public static bool Button(Rect position, Texture image, GUIStyle style);
使用示例:
1.
public static bool Button(Rect position, string text);
code-
1 void OnGUI(){ 2 if (GUI.Button(new Rect(10, 10, 100, 50),"Button")) 3 { 4 print("用户单击了按钮"); 5 } 6 }
2.
public static bool Button(Rect position, Texture image);
code-
1 public Texture btnTexture; 2 void OnGUI(){ 3 if (GUI.Button(new Rect(10, 10, 512, 256),btnTexture)) 4 { 5 print("用户单击了按钮"); 6 } 7 }
3.
public static bool Button(Rect position, GUIContent content);
code-
1 public Texture btnTexture; 2 void OnGUI(){ 3 if (GUI.Button(new Rect(10, 10, 512, 256),new GUIContent("Button",btnTexture))) 4 { 5 print("用户单击了按钮"); 6 } 7 }
4.tooltip
1 void OnGUI(){ 2 if (GUI.Button(new Rect(10, 10, 120, 100),new GUIContent("Button","这是一个按钮"))) 3 { 4 print("用户单击了按钮"); 5 } 6 GUI.Label(new Rect(10,120,100,20),GUI.tooltip); 7 }
GUIStyle需要事先定义和导入,暂时没做就不写了;
标签:style blog http color io os 使用 2014 div
原文地址:http://www.cnblogs.com/lhyz/p/3985078.html