So, i have this button, i want it to hide a GameObject when it is pressed. i’ve tried numerous codes and mixing and matching with no luck. I’m in no way a coder and this has me stumped… i’m sure it’s been answered elsewhere, i’ve searched high and low through various google searches and keep getting errors or only getting the button to disable. I know it’s pretty simple but i have no idea what i’m doing in general.
the name of the GameObject is ObjectChunk
private var ObjectChunk : GameObject[];
function OnMouseEnter(){
}
function OnMouseUp(){
ObjectChunk.gameObject.active = false;
}
this script is attached to a plane with a texture on it.
if any other info is needed let me know.
private var ObjectChunk : GameObject[];
function OnGUI(){
if(Rect(10,10, 100, 30), "Hide")
OnMouseUp();
}
function OnMouseUp(){
for(i : int = 0; i< ObjectChunk.Lenght; i++)
{
ObjectChunk[i].gameObject.SetActive(false);
}
}
UPDATE: You have an array of objects in the ObjectChunk variable, and if you want to change it you need to set the Index of object wich you want to change: