Skip to content

Unity

General notes about the Unity game engine, written from the perspective of a developer with extensive experience in the Source engine.

Scenes

Scenes are essentially Unity’s equivalent of maps. Only one scene is active at a time, but you can transition between scenes using code.

Scripts

Scripts in Unity are typically written in C# and must be attached to a object or exist in the scene hierarchy to run. Simply having a script in the Assets folder will not execute it.

  • Public variables appear in the Inspector.
  • Private variables do NOT appear in the Inspector.
    • SerializeField = Allows a private variable to be exposed in the Inspector, similar to public variables.

Classes

  • Object = The base class for all Unity objects. Provides basic functionality like instantiation and destruction, but not much beyond that.
  • GameObject = Subclass of Object and the base type for all entities in a scene. Every GameObject has a Transform component by default and can have additional components attached.
    • Component.gameObject = Used to access the GameObject from a component attached to it. For example, from a Transform component you would call transform.gameObject to access it.

Initial creation: Apr 17, 2021