Krotox Engine › Docs › Krotox Manual › The Editor

Scenes, prefabs & Play mode

The everyday loop in Krotox: building a scene from entities, parenting and grouping, turning entities into prefabs, testing with Play and Simulate, and managing many levels.

A Krotox game is a set of scenes (.ktx files). A scene holds entities; an entity holds components. This page covers how you build scenes, reuse parts of them, and test them.

Creating entities

Right-click in the Hierarchy and open Create:

SubmenuCreates
Empty Entity / Empty GroupAn entity with just a Transform, or an organizing group.
CameraAn entity with a Camera component. Every scene needs one primary camera.
World TextA text entity that lives in the world (not the UI).
2D ObjectSprite, Animated Sprite, Circle, Capsule, Ring, Diamond, Triangle, Hexagon, Star, Platform, Bar (Separator) and 2D Particle System.
UICanvas, World Space Canvas, Button, Image, Text, Vertical / Horizontal / Grid Layout, and Mask (Clip Region).

You can also press Shift+A over the Viewport to drop a shape at the cursor, or drag a sprite or prefab from the Content Browser into the scene.

After creating an entity, select it and use Add Component in the Properties panel to give it behaviour: a Rigidbody 2D and a collider for physics, a Script for your C# code, and so on. See the 2D component reference.

Parenting and groups

Drag an entity onto another in the Hierarchy to make it a child. A child's Transform is relative to its parent: move the parent and the child comes along. Use parenting for anything that belongs together, such as a character and its weapon, or a door and its hinge.

Deactivating a parent (the active toggle in the Properties header) hides its whole subtree. This is the simplest way to switch a menu, a level section or an enemy group on and off.

Prefabs

A prefab is a saved entity tree you can place many times and spawn from code.

  1. Build the entity in the scene: components, children, script fields.
  2. Right-click it in the Hierarchy and choose Create Prefab. A .prefab file appears in the Content Browser.
  3. Drag the prefab into any scene to place an instance. Instances are marked as *Prefab instance of ...* in the Hierarchy.
  4. Open the .prefab from the Content Browser to edit it in prefab edit mode. A banner shows you are editing the prefab, and Ctrl+S saves the prefab rather than the scene.

From code, drop the prefab onto a Prefab field in the inspector and call Instantiate(prefab, position). The spawned entity's scripts are fully started when Instantiate returns. See Prefabs, scenes & saving.

Testing: Play, Simulate, Pause and Step

ModeWhat runsUse it for
Play (F5)Scripts, physics, animation, audio, UIPlaying the game.
SimulatePhysics only, no scriptsChecking stacks, joints and ragdolls without gameplay code.
PauseNothing advancesInspecting the scene mid-game.
StepOne frameWatching physics frame by frame.
Stop—Back to editing. The scene returns to exactly how it was before Play.

When you press Play, the editor makes a copy of the scene, starts every script in a fixed order and starts the physics world. The copy is what you play; the original is untouched. That is why changes made during Play disappear when you stop.

Edit in Edit mode. Values you tweak during Play are not saved and cannot be undone. If you find a good value while playing, write it down, stop, then set it.

Press F11 to play full-window, and Escape to leave.

Saving

Working with many levels

The Level Stepper on the toolbar lists every .ktx scene in the project in natural order. Use < and > to move between levels, the dropdown to jump, and Rescan project for scenes to pick up new files. When you step away from a scene with unsaved changes it asks Save and Continue, Discard or Cancel.

Level Data opens the scene's *Level Metadata* component inline: name, chapter, index, target score, par time, required collectibles and three star thresholds. Scripts read the same data to award stars. See physics gameplay components.

Playtest plays the level you are looking at. Save first if you want your changes kept.

Which scenes ship

Only the scenes listed in File ▸ Build Settings go into a build. Add scenes with Add Scene to Build... or by dragging .ktx files from the Content Browser, and mark the first one with Set Start. See Building for Android.

Switching scenes in a game

Scenes load from scripts with SceneManager.LoadScene("Scenes/Level2.ktx"). Paths are relative to the Assets folder. ScriptCore also ships ready-made scripts that need no code:

ScriptLoads a scene when
SceneLoaderafter a delay, or when StartLoading() is called
SceneChangeButtonthe entity's UI button is pressed
SceneTransitionTriggerthe player (or any entity with the chosen tag) touches it

Each has a TargetScenePath field that shows a scene picker in the inspector.