void CreateCube(BoxParams b) { // incoming box from StartCube() is renamed b GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube); // b.width height and depth are used to change the size of the // box created by the line above go.transform.localScale = new Vector3(b.width, b.height, b.depth); go.GetComponent <MeshRenderer>().material.color = b.color; }
void StartCube() { // Called in Start() BoxParams box = new BoxParams(); box.width = 2; box.height = 3; box.depth = 4; box.color = Color.red; // calling to function with box params CreateCube(box); }