Per-frame lifecycle: Update, FixedUpdate, Start, OnDestroy and Time (#75) #81

Closed
opened 2026-09-06 01:24:54 +00:00 by crowmaki · 0 comments
Owner

Parent

#75

What to build

A Script Component's Update(dt), FixedUpdate(dt), Start() and OnDestroy() methods run from the Plugin's Hooks and the Schema's Component Hooks, the Unity way. The Plugin's update and fixed_update Hooks walk each Script class in Schema registration order and, within a class, walk component_storage by index, re-fetching storage every iteration because a call into a Script may add Components and move it. Start runs immediately before the first Update of an instance whose Transient started bit is clear, then sets the bit; the bit is a Transient Field the host declares in the description, not a Core concept. Instances on a GameObject that is not Active in Hierarchy are skipped by Update, FixedUpdate and therefore Start. OnDestroy runs from on_remove, exactly once whichever way the Component leaves.

A Time table with deltaTime, fixedDeltaTime and frameCount is refreshed at the top of each Hook from Frame Timing. A runtime error in one instance's Update is logged with a Luau traceback and the rest of the frame continues.

Acceptance criteria

  • Update runs once per frame per live instance, and FixedUpdate once per fixed step, with counts checked across a multi-step Tick using engine_tick_with_delta
  • Start runs exactly once per instance, on the first frame it is updated, after every Component on the same GameObject added that frame has run Awake
  • An instance on an inactive GameObject, or under an inactive ancestor, receives no Start, Update or FixedUpdate until the subtree is active again
  • OnDestroy runs exactly once for direct Component removal, for owner GameObject destruction, and for Scene unload
  • Classes update in Schema registration order and instances within a class in storage order, stable across frames
  • Time.deltaTime, Time.fixedDeltaTime and Time.frameCount match the Frame Timing the Hook received
  • An error thrown by one instance's Update is logged with a traceback and every other instance in that frame still updates
  • The started bit does not reach a Scene Document (it is Transient)

Blocked by

## Parent #75 ## What to build A Script Component's `Update(dt)`, `FixedUpdate(dt)`, `Start()` and `OnDestroy()` methods run from the Plugin's Hooks and the Schema's Component Hooks, the Unity way. The Plugin's `update` and `fixed_update` Hooks walk each Script class in Schema registration order and, within a class, walk `component_storage` by index, re-fetching storage every iteration because a call into a Script may add Components and move it. `Start` runs immediately before the first `Update` of an instance whose Transient started bit is clear, then sets the bit; the bit is a Transient Field the host declares in the description, not a Core concept. Instances on a GameObject that is not Active in Hierarchy are skipped by `Update`, `FixedUpdate` and therefore `Start`. `OnDestroy` runs from `on_remove`, exactly once whichever way the Component leaves. A `Time` table with `deltaTime`, `fixedDeltaTime` and `frameCount` is refreshed at the top of each Hook from Frame Timing. A runtime error in one instance's `Update` is logged with a Luau traceback and the rest of the frame continues. ## Acceptance criteria - [ ] `Update` runs once per frame per live instance, and `FixedUpdate` once per fixed step, with counts checked across a multi-step Tick using `engine_tick_with_delta` - [ ] `Start` runs exactly once per instance, on the first frame it is updated, after every Component on the same GameObject added that frame has run `Awake` - [ ] An instance on an inactive GameObject, or under an inactive ancestor, receives no `Start`, `Update` or `FixedUpdate` until the subtree is active again - [ ] `OnDestroy` runs exactly once for direct Component removal, for owner GameObject destruction, and for Scene unload - [ ] Classes update in Schema registration order and instances within a class in storage order, stable across frames - [ ] `Time.deltaTime`, `Time.fixedDeltaTime` and `Time.frameCount` match the Frame Timing the Hook received - [ ] An error thrown by one instance's `Update` is logged with a traceback and every other instance in that frame still updates - [ ] The started bit does not reach a Scene Document (it is Transient) ## Blocked by - #80
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
crowmaki/cinnabar#81
No description provided.