QuestForge Runtime Setup
QuestForgeRuntimeSetup.cs
Overview
QuestForgeRuntimeSetup is the scene-level initialisation component for the Quest Forge system. It serves two distinct responsibilities:
Shared Transform Injection — Populates shared Malbers
TransformVarScriptableObject assets with the runtime player and camera transforms. Every system that needs to know where the player or camera is (QuestManager, POIManager, MinimapUI, CompassBarUI, QuestEventReporter, etc.) references these sharedTransformVarassets rather than performing their own lookups. This component is the single place those assets get their values at runtime.Save System Bootstrap — After all
Start()methods in the scene have executed, it callsQuestSaveSystem.LoadGame()to restore quest and dialogue state, then notifies everyQuestTriggerandDialogueTriggerin the scene to re-evaluate whether they should be deactivated or destroyed based on that loaded state.
This component should be placed on a persistent scene manager GameObject, typically as part of the QuestForgeManagers prefab.

Inspector Properties
Shared Variables
Player Transform Var
The TransformVar ScriptableObject asset that all Quest Forge systems use to find the player. This component writes to it at Start; other systems read from it.
Main Camera Transform Var
The TransformVar ScriptableObject asset that UI systems (minimap, compass, world-space labels) use to find the main camera.
Auto-Find Settings
Auto Find Player
When enabled, searches for a GameObject with the specified tag and assigns its Transform to Player Transform Var.
Player Tag
The Unity tag used to locate the player. Default is "Player".
Auto Find Camera
When enabled, uses Camera.main to find the main camera and assigns its Transform to Main Camera Transform Var. Requires the scene camera to be tagged "MainCamera".
Manual References (Optional)
Manual Player Transform
A directly assigned player Transform. Takes priority over Auto-Find if set.
Manual Camera Transform
A directly assigned camera Transform. Takes priority over Auto-Find if set.
Priority order: Manual Reference → Auto-Find. If a manual reference is assigned, auto-find is skipped entirely for that target.
Save System Integration
Auto Load On Start
When enabled, automatically calls QuestSaveSystem.LoadGame() at scene start to restore all saved quest and dialogue state.
Auto Load Delay
Seconds to wait before loading. Set to 0 for immediate load (runs at end of frame, after all Start() methods). Any value above 0 uses Invoke with the specified delay.
Debug
Debug Mode
Enables detailed log output via QuestLogger for all initialisation steps.
How It Works
Transform Initialisation
On Start(), the component resolves the player and camera transforms in the following order for each:
If a Manual Reference is assigned, use it directly
Otherwise, if Auto-Find is enabled, search by tag (
GameObject.FindGameObjectWithTag) orCamera.mainIf a transform is found, write it into the corresponding
TransformVarScriptableObject
Because TransformVar is a ScriptableObject, any other component that holds a reference to the same asset instantly sees the updated value — no scene coupling required.
Save System Bootstrap
When Auto Load On Start is enabled and no delay is set, the load runs inside a coroutine that waits for WaitForEndOfFrame. This guarantees that every component's Start() method has finished executing before the save data is applied. This is important because QuestTrigger and DialogueTrigger components initialise their trigger IDs in Start() — if the save loaded before that, the ID lookup would fail.
The load sequence is:
Verify
QuestSaveSystem.Instanceis available (retries every 0.1s if not yet ready)Call
QuestSaveSystem.Instance.LoadGame()If successful, call
NotifyTriggersToRecheck()— finds everyQuestTriggerandDialogueTriggerin the scene and callsRecheckSavedState()on eachEach trigger checks whether its unique ID appears in the loaded save data and applies the appropriate state (destroy, deactivate, or mark as already triggered)
Public API
SetPlayer(Transform newPlayer)
Updates Player Transform Var with a new transform at runtime. Use for character switching or late-spawned players.
SetCamera(Transform newCamera)
Updates Main Camera Transform Var with a new transform at runtime. Use when switching between cameras.
GetPlayerTransform()
Returns the Transform currently stored in Player Transform Var, or null if not set.
GetCameraTransform()
Returns the Transform currently stored in Main Camera Transform Var, or null if not set.
RefreshPlayer()
Re-runs the player initialisation logic (manual check → auto-find). Use when the player spawns after Start().
RefreshCamera()
Re-runs the camera initialisation logic. Use when the main camera changes after Start().
ManualLoadSavedData()
Manually triggers the full save load sequence. Can be bound to a UI button or called from code.
Custom Inspector (Play Mode)
When the scene is running, the Inspector shows a live status panel with:
Current Player — the name of the transform currently in
Player Transform VarCurrent Camera — the name of the transform currently in
Main Camera Transform VarRefresh Player / Refresh Camera buttons — re-runs the respective initialisation without restarting the scene
Load Saved Data button — manually triggers a full save load
Save Current Data button — manually calls
QuestSaveSystem.Instance.SaveGame()Live counters — Active Quests, Completed Quests, Dialogue Triggers Completed, Quest Triggers Activated
Setup Instructions (ONLY PERFORM IF NEEDED)
The Helpers Tools One-Click Setup already does this - you should never have to do this yourself!
Create two
TransformVarScriptableObject assets (e.g.Runtime_PlayerTransformandRuntime_MainCamera). These live in your project as assets, not in the scene.Assign both assets to this component's Shared Variables fields.
Assign the same assets to every other system that needs them:
QuestManager.Player Transform,POIManager.Player Transform,MinimapUI.Player Transform,CompassBarUI.Player Transform,QuestEventReporter.Player Transform, etc.At runtime,
QuestForgeRuntimeSetupwrites to those assets once, and all systems automatically have a valid reference.
Other Notes
This component does not use
DontDestroyOnLoad. It is a scene-level component. If you load a new scene, a fresh instance of this component should be present in that scene to re-initialise theTransformVarassets for the new scene's player and camera.If
Auto Load Delayis set to0, the load still runs one frame after allStart()methods viaWaitForEndOfFrame— it is not truly immediate. This is by design to prevent timing conflicts with trigger ID initialisation.QuestSaveSysteminitialises inAwake. If for any reason it is not ready whenLoadSavedData()runs, the method retries automatically every 0.1 seconds until it becomes available.NotifyTriggersToRecheck()usesFindObjectsOfType<QuestTrigger>()andFindObjectsOfType<DialogueTrigger>(). This is a scene-wide search and may have a minor performance cost on scenes with large numbers of triggers — it only runs once per load.
Last updated