Scenes and scene nodes

Scenes

A scene is a tree of nodes that represents something in your game — a level, a menu, a character, a UI screen. Scenes are saved as .prefab files anywhere under Assets/:

Assets/
  scene-01.prefab       ← the starter scene of a new project
  Levels/
    forest.prefab
  Enemies/
    grunt.prefab

The startup scene is the first one loaded when your game starts. It is set in the project's Player Settings.

Create a scene from the Assets panel: right-click a folder → New → Scene. Double-click a scene to open it; each open scene gets a tab at the top of the window.

Nodes

A node is a single element of a scene. Nodes are organised in a tree: each node has one parent and any number of children, and transforming a parent transforms its children too.

Main Scene
├── Camera
├── Sun
├── Ground
│   ├── Tree        (moves with Ground)
│   └── Rock
└── Player
    └── Weapon

Every node has a Transform — position, rotation (Euler angles in degrees, stored as a quaternion) and scale. An empty node is still useful: as a spawn point, a pivot, or a parent that groups other nodes.

Working with nodes in Studio

In the Scene Tree panel:

  • Click a node to select it; the Inspector shows its transform and components.
  • Right-click for New Node, New Child Node, Rename, Delete, Copy and Paste.
  • F2 renames, Delete deletes and D duplicates the selected node.
  • Drag a script from the Assets panel onto a node to add that component.

In the Scene view, select a node and use the Move (W), Rotate (E) and Scale (R) tools; F frames the selection. See Gizmos.

Save with Ctrl+S (or Ctrl+Shift+S to save every open document).

Nodes in code

public override void OnStart()
{
    var node = Node!;                                  // the node this component is on
    node.Name = "Player";
    node.Transform.Position = new Vector3(0, 1, 0);

    foreach (var child in node.Children)               // direct children
        child.IsActive = true;

    var light = node.GetComponent<LightComponent>();   // null when absent
    foreach (var mesh in node.GetComponentsInChildren<ModelComponent>())
        mesh.IsActive = false;
}

To spawn new objects at runtime, instantiate a prefab — see Instantiating scenes.

The scene file on disk

A .prefab file stores the whole node tree as JSON, readable and diff-friendly. Each object carries a __TypeId — a stable id of its C# type — so scenes survive renaming or moving classes:

{
  "__TypeId": "a3000000-0000-4000-8000-000000000002",
  "IsActive": true,
  "Name": "Main Scene",
  "Children": [
    {
      "__TypeId": "a3000000-0000-4000-8000-000000000002",
      "IsActive": true,
      "Name": "Camera",
      "Children": [],
      "Components": [
        { "__TypeId": "a3000001-0000-4000-8000-000000000001", "FieldOfViewDegrees": 60, "NearPlane": 0.01, "FarPlane": 100 }
      ],
      "Transform": {
        "Position": { "X": 0, "Y": 2, "Z": -6 },
        "Orientation": { "X": 0, "Y": 0, "Z": 0, "W": 1 },
        "Scale": { "X": 1, "Y": 1, "Z": 1 }
      },
      "Id": "e0224d28-0849-45fc-a09c-ba8645113a9e"
    }
  ],
  "Components": [],
  "Id": "7d1f4c2a-…"
}

You rarely need to edit scene files by hand, but the format makes it easy to review changes in Git and resolve merge conflicts.


← All docs Edit this page