can any one help me … what does this mean???..how can i do that???
//again, cube is a varible defined elsewhere …is it like though a Var:GameObject?
can any one help me … what does this mean???..how can i do that???
//again, cube is a varible defined elsewhere …is it like though a Var:GameObject?
You cannot destroy a cube with the press of a GUI button?
Then I will conclude that you are pretty new to Unity. Amirite?
I would recommend you watching some tutorials just to get you started.
And this:
When you are done watching all of hes tutorials you will properly more or less have all the basic skills needed to destroy a cube with a GUI button.
You can also(if you do not want to watch the tutorials) take a look at the destroy function.
Maybe this as well
Although I don’t know if it has to be a GameObject, or some other variable type, what you have to do is to define a variable named Cube at the top of your script like this
var Cube : GameObject;
And then you can drag and drop the cube from the inspector view of that script to assign a value to the variable.
PD: I assumed that you were doing it in JavaScript
Yes you define GameObjects via variables. If you only have one cube you pre-define it as this:
var myCube : GameObject;
function Update () {}
Or you could do this at runtime with something like (never do finding in Update due to performance):
function theFunction () {
var myCube = GameObject.Find("TheNameOfYourCube");
}
To access objects from other scripts you use:
theObject.GetComponent(TheThingYouWantToAccess).theStuffInsideTheThing
Good reading: