| Term | Definition |
|---|---|
| Design pattern | A general, reusable solution or best practice for commonly occurring problems in software design. A template for how to solve a problem that can be used in many different situations. Wikipedia. |
| Game design pattern | Design patterns specifically for games. See Bob Nystrom's Game Programming Patterns, 2014 for a good overview. |
| Singleton pattern | A software design pattern that restricts the instantiation of a class to one. This is useful when exactly one object is needed to coordinate actions across the system. For example, singletons can be helpful when you have a single class that provides functionality to several other classes in your game, such as coordinating game logic in a Game Manager class. Wikipedia. |
| Composite pattern | The composite pattern (a.k.a. composition over inheritance principle) says classes should achieve polymorphic behavior and code reuse by their composition (by containing instances of other classes that implement the desired functionality) rather than inheritance from a base or parent class. Wikipedia. In Unity, each GameObject can have multiple components attached to them, with each component providing different functionality. Read an analogy describing how this is different than inheritance. |
| Term | Definition |
|---|---|
| Modifiers | Modifiers are used to modify declarations of types and type members. |
const |
Constant fields and locals aren't variables and may not be modified. Constants can be numbers, Boolean values, strings, or a null reference. Don’t create a constant to represent information that you expect to change at any time. |
static |
Declares a member that belongs to the type itself instead of to a specific object. |
virtual |
Used to declare that classes, methods, or variables can be implemented in the current class but can also be overridden in an inheriting class if the current implementation is not sufficient. |
abstract |
Indicates that a class is intended only to be a base class of other classes. Members marked as abstract, or included in an abstract class, must be implemented by classes that derive from the abstract class. |
override |
Provides a new implementation of a virtual member inherited from a base class. It is required to extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event. |
| Access modifiers | Access modifiers are keywords used to specify the declared accessibility of a member or a type. The three access modifiers you will see most often in C# are: public (access not restricted), protected (access limited to containing class or types derived from containing class), internal (the default, access is limited to the current assembly), and private (access limited to the containing type). Microsoft. |
| Term | Definition |
|---|---|
Object |
Base class for all objects Unity can reference. Any public variable you make that derives from Object gets shown in the inspector as a drop target. |
Object.name |
The name of the object. |
Object.Destroy() |
Removes a gameobject, component or asset. |
MonoBehaviour.OnEnable() |
This function is called when the object becomes enabled and active. |
MonoBehaviour.OnDisable() |
This function is called when the behaviour becomes disabled. Also called when the object is destroyed and can be used for any cleanup code. |
GameObject |
Base class for all entities in Unity Scenes. |
GameObject.name |
Inherited from Object.name; |
GameObject.SetActive() |
Activates/Deactivates the GameObject. Making a GameObject inactive will disable every component, turning off any attached renderers, colliders, rigidbodies, scripts, etc. Any scripts that you have attached to the GameObject will no longer have Update() called, for example. |
GameObject.GetComponent() |
Returns the component of Type type if the game object has one attached, null if it doesn't. GetComponent is the primary way of accessing other components. You can access both builtin components or scripts with this function. |
Component |
Base class for everything attached to GameObjects. |
Component.gameObject |
The game object this component is attached to. A component is always attached to a game object. |
Vector2 |
A data structure used throughout Unity to represent 2D positions and directions. |
Vector3 |
A data structure used throughout Unity to represent 3D positions and directions. Also contains functions for doing common vector operations. |
- You can only
overridemethods not fields(variables);virtualandabstractare only valid on methods
- Unity Manual and Unity Scripting Reference
- Chapter 7 in Halpern, Jared. Developing 2D Games with Unity. APress, 2019.
