スクリプトからCubeを生成する方法を自分用にメモ。
[ 生成方法 ]
「GameObject.CreatePrimitive(PrimitiveType.Cube);」で生成できます。
[ 使用例 ]
下記はCubeを生成し、生成したCubeの座標を(10, 20, 30)にするスクリプトです。
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScriptTest : MonoBehaviour { void Start() { GameObject Cube = GameObject.CreatePrimitive(PrimitiveType.Cube); Cube.transform.position = new Vector3(10, 20, 30); } }