Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity create cube in script

void Start()
    {
    	/*GameObject != gameObject*/
        GameObject cubeObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
        
        /*if you need add position, scale and color to the cube*/
        cubeObject.transform.localPosition = new Vector3(0, 1, 0);
        cubeObject.transform.localScale = new Vector3(1, 1, 1);
        cubeObject.GetComponent<MeshRenderer>().material.color = Color.red  ;
    }
 
PREVIOUS NEXT
Tagged: #unity #create #cube #script
ADD COMMENT
Topic
Name
4+1 =