I have this script and would like turn it to be GUI button, I don't know how to define show into ToggleVisibility.
Anyone can help?
Thanks
var show : Transform;
function Update() {
if (Input.GetKeyDown(KeyCode.Z)) {
ToggleVisibility();
}
}
function ToggleVisibility() {
// toggles the visibility of this gameobject and all it's children
show = gameObject.GetComponentsInChildren(Renderer);
for (var r : Renderer in show) {
r.enabled = !r.enabled;
}
}
var show : Transform;
function OnGUI()
{
if (GUI.Button (Rect (20,20, 30, 20), "toggle")
ToggleVisiblilty();
}
function Update() {
if (Input.GetKeyDown(KeyCode.Z)) {
ToggleVisibility();
}
}
function ToggleVisibility() {
// toggles the visibility of this gameobject and all it's children
var thisR = GetComponent(Renderer);
thisR.enabled = !thisR.enabled;
show = gameObject.GetComponentsInChildren(Renderer);
for (var r : Renderer in show) {
r.enabled = !r.enabled;
}
}