Hello everyone !
I am at the beginning phase of developing with Unity and I have this code to add a game object (simple cube) at the press of a button.
private void OnGUI()
{
if (GUI.Button(new Rect(50, 50, 25, 25), "+"))
{
GameObject newCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
int randNum = Random.Range(2, 5);
newCube.transform.position = new Vector3(randNum, randNum, randNum);
}
}
So my question is how to add gravity or even textures to these newly added cubes ?
Thanks in advance and sorry for any mistakes I might have slipped in, if any.
Dan.
↧