GUI
- backgroundColor
- BeginGroup
- BeginScrollView
- Box
- BringWindowToBack
- BringWindowToFront
- Button
- changed
- color
- contentColor
- depth
- DragWindow
- DrawTexture
- enabled
- EndGroup
- EndScrollView
- FocusControl
- FocusWindow
- GetNameOfFocusedControl
- GUI
- HorizontalScrollbar
- HorizontalSlider
- Label
- matrix
- PasswordField
- RepeatButton
- ScrollTo
- SelectionGrid
- SetNextControlName
- skin
- TextArea
- TextField
- Toggle
- Toolbar
- tooltip
- UnfocusWindow
- VerticalScrollbar
- VerticalSlider
- Window
GUI.skin 皮肤
static var skin : GUISkin
The global skin to use.
You can set this at any point to change the look of your GUI. If you set it to null, the skin will revert to the default Unity skin.
全局皮肤使用。你可以在任何时候改变GUI外观,如果你设置为null,那么皮肤将恢复默认的Unity GUI皮肤。
//定义皮肤数组,在检视面板添加几个定义皮肤进来测试效果
var s1 : GUISkin[];
private var hSliderValue : float = 0.0;
private var vSliderValue : float = 0.0;
private var hSValue : float = 0.0;
private var vSValue : float = 0.0;
private var cont : int = 0;
function Update() {
if(Input.GetKeyDown(KeyCode.Space))
//按空格累加cont数
cont++;
}
function OnGUI() {
//通过你指定的数组长度和空格累加数求余来指定皮肤
GUI.skin = s1[cont%s1.Length];
if(s1.Length == 0){
Debug.LogError("Assing at least 1 sking on the array");
//如果不指定皮肤文件,则返回,不执行下面的代码。
return;
}
//下面是几个GUI元素
GUI.Label(Rect(10, 10, 100, 20), "Hello World!");
GUI.Box(Rect(10, 50, 50, 50), "A BOX");
if (GUI.Button(Rect(10,110,70,30), "A button"))
Debug.Log("Button has been pressed");
hSliderValue = GUI.HorizontalSlider(Rect(10, 150, 100, 30), hSliderValue, 0.0, 10.0);
vSliderValue = GUI.VerticalSlider(Rect(10, 170, 100, 30), vSliderValue, 10.0, 0.0);
hSValue = GUI.HorizontalScrollbar(Rect(10, 210, 100, 30), hSValue, 1.0, 0.0, 10.0);
vSValue = GUI.VerticalScrollbar(Rect(10, 230, 100, 30), vSValue, 1.0, 10.0, 0.0);
}
最后修改:2011年1月14日 Friday 22:34