Advanced Tutorial 5: How to Reference and Change a GameObject

{|
 * style="width: 1100px;" |

Introduction
Your scene in The Endless Mission is filled with assets called Entities. Using this Entity System allows The Endless Mission to save complex data about the object such as the EndlessEvents and properties that you have on it. Because these objects are saved as "Entities" you have to manually get a reference to the GameObject contained in the Entity. Doing this allows you to access and change all of the wonderful properties that GameObjects have to offer such as: Positional coordinates, rotation, visibility, behavior, pretty much anything you could want to do. {|
 * }
 * }
 * style="width: 1100px;" |

Getting the GameObject

 * 1. In your "Barebones Game" scene, place an object anywhere.
 * 2. Make and name a new script on this object.
 * 3. Declare a variable of the Type EntityReference.
 * 4. Add a [SerializeField] tag in the line above this variable to access it in the inspector. It should look like this:

[SerializeField] private EntityReference myEntity;
 * 5. Take the time now to drag the Entity you want to change into the new field in the inspector.
 * 6. To get the GameObject of this Entity you can simply write the following inside of the Start or Awake functions:

private GameObject myGameObject = myEntity.GameObject
 * 7. From myGameObject you have access to tons of cool properties and variables attached to this Entity. For example, to change the position of the object:

myGameObject.transform.position = new Vector3(0, 0, 0);
 * or disable the object in the scene:

myGameObject.SetActive(false); for a full list of the cool things you can do, check out: GameObjects.




 * }
 * }