Example 1: gameobject in unity c#
public GameObject myObject;
void Start()
{
myObject.name = "myObjectsNewName";
}
Example 2: unity create gameobject with component
GameObject go = new GameObject("Test", typeof(MeshRenderer), typeof(MeshFilter), typeof(YourScript));
Example 3: unity create gameobject
SpawnedObject = new GameObject("Created GameObject");
Example 4: how to add a gameobject
public void AddGameObject()
{
GameObject testObject = new GameObject("Name_1");
}
Example 5: create gameobject unity
using UnityEngine;
public class InstantiationExample : MonoBehaviour
{
public GameObject myPrefab;
void Start()
{
Instantiate(myPrefab, new Vector3(0, 0, 0), Quaternion.identity);
}
}
Example 6: unity create empty gameobject in code
objToSpawn = new GameObject("Cool GameObject made from Code");
Comments
Post a Comment