Unity lets you make games of any kind for any platform. It’s revolutionary but its flexibility can lead to a system which is hard to understand. Here’s what I learnt making my game as a handy reference.


Which building blocks do I use and when?

GameObject ScriptableObject MonoBehaviour No inheritance
What The entities that interact with each other. Data models editable via Unity UI. GameObject actions and data flow. Basic C# class.
When If it can be seen in the game world. To define the settings of GameObjects and general configuration. To control GameObjects, generate and handle events. When behaviour not directly related to a GameObject.
Where Lives in the Hierarchy. Lives in the ProjectView. Initialized by Unity. Attached to GameObjects as a Component, or lives in the Hierarchy. Lives in the ProjectView. Called programatically by other scripts.
Example Scene.unity Config : ScriptableObject PlayerController : MonoBehaviour SaveController
Use Cases
  • Player
  • Camera
  • Scene
  • Player
  • Config
  • Player
  • Camera
  • Scene
  • Saves
  • User Input
  • Utilities


In Unity most things are GameObjects which scripts are attached to. In your scripts you can access most things with these 3 snippets:

If you’re searching for GameObjects in the Scene Hierarchy:


Using breakpoints via Visual Studio is the best way to debug complex data flows, but sometimes you just want good old fashioned debugging.

List components and all their variables

Put using System.Reflection; at top of file then paste:

Component[] components = (Component[]) GetComponents (typeof(Component));
foreach (Component c in components) {
  Debug.Log("Name: " + c.name + " Type: " + c.GetType() + " BaseType: " + c.GetType().BaseType);
  foreach (FieldInfo field in c.GetType().GetFields()) {
    System.Object obj = (System.Object) c;
    Debug.Log("Name: " + field.Name + " Value: " + field.GetValue(obj));


You will need to keep running the main scene and navigating to it in Unity then running it is tedious. Create a keyboard shortcut instead with:

using UnityEditor;
using EditorSceneManager = UnityEditor.SceneManagement.EditorSceneManager;

public static class PlayMainMenu {
  // Add keyboard shortcut.
  [MenuItem("Edit/Play Main Menu _m")]
  public static void PlayFromPrelaunchScene() {
    if (EditorApplication.isPlaying) {
      EditorApplication.isPlaying = false;
    EditorApplication.isPlaying = true;

Replace <scene-name> with the name of your scene. Now M key on your keyboard will run the main scene from anywhere.