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