unity create gameobject in code code example
Example 1: unity create gameobject
SpawnedObject = new GameObject("Created GameObject");
Example 2: create gameobject unity
using UnityEngine;
public class InstantiationExample : MonoBehaviour
{
public GameObject myPrefab;
void Start()
{
Instantiate(myPrefab, new Vector3(0, 0, 0), Quaternion.identity);
}
}
Example 3: unity create empty gameobject in code
objToSpawn = new GameObject("Cool GameObject made from Code");
Example 4: create new gameobject unity
GameObject newLocation = new GameObject("name");