unity instantiate new gameobject code example
Example 1: unity instantiate
clone = Instantiate(original);
clone = Instantiate(original, new Vector3(0, 0, 0), Quaternion.identity, cloneParent.transform);
Example 2: how to create empty ui object unity
GameObject myGO = new GameObject("MyGO", typeof(RectTransform),typeof(Button));
Example 3: how to instantiate a gameobject
public void AddGameObject()
{
GameObject testPrefab = new GameObject("Name_1");
Vector3 objectPOS = Vector3.zero;
GameObject newGameObject = Instantiate(testPrefab, objectPOS, Quaternion.identity);
}
Example 4: instantiate object unity
public static Object Instantiate(Object original);
public static Object Instantiate(Object original, Transform parent);
public static Object Instantiate(Object original, Transform parent, bool instantiateInWorldSpace);
public static Object Instantiate(Object original, Vector3 position, Quaternion rotation);
public static Object Instantiate(Object original, Vector3 position, Quaternion rotation, Transform parent);
Example 5: unity create empty gameobject in code
objToSpawn = new GameObject("Cool GameObject made from Code");