Skip to content
Agentmart
Submit a tool

MonoObjLifecycle

MonoObj 更新生命週期系統的使用指南。當需要:(1) 了解 WorldUpdateSimulator 的更新迴圈架構 (2) 實作 Simulate、Render 等每幀更新邏輯 (3) 新增…

Skill by RED-CANDLE-GAMES-CO-LTD

IndexedMIT★ 25
Write a review

Chalk Labs

Need help deploying MonoObjLifecycle?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/red-candle-games-co-ltd-monoobjlifecycle

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

MonoObj 更新生命週期系統的使用指南。當需要:(1) 了解 WorldUpdateSimulator 的更新迴圈架構 (2) 實作 Simulate、Render 等每幀更新邏輯 (3) 新增 IUpdateSimulate、IBeforeSimulate、IAfterSimulate、IRenderUpdate 實作 (4) 理解 MonoObj 註冊/反註冊流程 (5) 理解 local FixedUpdate/LateUpdate 與 Fusion FixedUpdateNetwork/Render 時機 (6) 拆分 simulation/render culling (7) 一次性初始化該用 ISceneAwake / ISceneStart、或初始化沒被呼叫 / GetVar 拿到 null 的時序問題時使用此 skill。

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/monoobjlifecycle

What's inside

Skill name
MonoObjLifecycle
Description
MonoObj 更新生命週期系統的使用指南。當需要:(1) 了解 WorldUpdateSimulator 的更新迴圈架構 (2) 實作 Simulate、Render 等每幀更新邏輯 (3) 新增 IUpdateSimulate、IBeforeSimulate、IAfterSimulate、IRenderUpdate 實作 (4) 理解 MonoObj 註冊/反註冊流程 (5) 理解 local FixedUpdate/LateUpdate 與 Fusion FixedUpdateNetwork/Render 時機 (6) 拆分 simulation/render culling (7) 一次性初始化該用 ISceneAwake / ISceneStart、或初始化沒被呼叫 / GetVar 拿到 null 的時序問題時使用此 skill。
License
MIT
Instructions
166 lines in SKILL.md · view on GitHub

Agent Skills spec issues

  • name: only lowercase letters, digits and single hyphens allowed

Files (2)

  • SKILL.md
  • SKILL.md.meta

SKILL.md (first lines)

# MonoObj Lifecycle

MonoObj 的每幀更新透過 `WorldUpdateSimulator` 集中管理,以介面驅動方式分階段執行。

## 執行時序

```
LocalSimulatorRunner.FixedUpdate / FusionSimulatorRunner.BeforeTick + FixedUpdateNetwork
├── World.BeforeSimulate(...)               → IBeforeSimulate
├── World.Simulate(...)                     → IUpdateSimulate
└── World.AfterSimulate(...)                → IAfterSimulate

LocalSimulatorRunner.LateUpdate / FusionSimulatorRunner.Render
└── World.Render(...)                       → IRenderUpdate

LocalSimulatorRunner.LateUpdate 尾段 / FusionSimulatorRunner.AfterRender
└── World.AfterRender()                     → IAfterRenderMono
```

每顆註冊的 `MonoObj` 都是獨立 scope。`[AutoChildren(StopAtType = typeof(MonoObj))]`
不會跨進 nested MonoObj;nested MonoObj 會自己註冊並被 WorldUpdateSimulator 呼叫,不是由 root
遞迴代跑。

## 初始化時序:ISceneAwake / ISceneStart

一次性初始化不要寫在 Unity 的 `Awake()` / `Start()`,改用這兩個介面(都在 global namespace,
定義於 `MonoFSM/1_MonoFSM_Core/Runtime/Entity/IResetter.cs`):

| 介面 | 方法 | 時機 |
|---|---|---|
| `ISceneAwake` | `EnterSceneAwake()` | 由 `WorldUpdateSimulator.WorldInit()` 分派,早於 ISceneStart |
| `ISceneStart` | `EnterSceneStart()` | WorldInit 後段,此時 `MonoDict` 等系統已 prepared |

WorldInit 的觸發點:單機是 `LocalSimulatorRunner.Start()`;Fusion 是
`FusionSimulatorRunner.OnSceneLoadDone()`(幾乎鐵定晚於一般 Unity `Start()`)。

### 坑 1:ISceneAwake 只由 MonoObj 對自己子樹分派

`MonoObj`(`MonoFSM/1_MonoFSM_Core/Runtime/LifeCycle/Update/MonoObj.cs`)是對自己的
`GetComponentsInChildren<ISceneAwake>` 分派;`SceneLifecycleManager.HandleGameLevelAwake(level)`
同樣只掃指定 level 物件的子樹。

→ 直接在 scene 建一顆**裸 root GameObject** 掛 `ISceneAwake` 元件,**`EnterSceneAwake()` 永遠不會被呼叫,
而且完全沒有錯誤訊息**。症狀是「元件欄位都填好了但初始化沒發生」(例如 static 注入仍是 null)。

做法:這類「場景放一顆就好」的 installer 要掛在某個帶 `MonoObj` 的節點子樹下(本專案用
`FusionFPS Core/GameCore`)。除錯時先檢查它要寫的目標值是否真的被設,再往上確認 parent 有沒有 MonoObj。

`MonoObj._sceneStarts` 是 `[AutoChildren]` 的 interface array,runtime 由 AutoAttributeManager 重抓,
改完不需要重存 prefab(除非該 prefab 有 `PrefabSerializeCache`)。

### 坑 2:在 Start() 裡呼叫 GetVar 會靜默拿到 null

`MonoDict.Get(key)`(`MonoFSM/1_MonoFSM_Core/Runtime/0_Pattern/MonoDict.cs`)在
`_isPrepared == false && Application.isPlaying` 時只印一行 `GetFrom {key} Dict, Not prepared` 就回 `default`。
`_isPrepared` 要等 `MonoDict.EnterSceneAwake()`,也就是 WorldInit 之後才成立。

→ 任何在 Unity `Start()` 裡呼叫 `entity.GetVar(tag)` / `VariableFolder.GetVariable(...)` 的程式碼都不保證拿得到東西。
危險的是常見的過濾寫法 `RemoveAll(e => e.GetVar(tag) == null)`:整份清單被清空,又只 cache 一次不會重抓 ——
Console 只留一行 error,遊戲端是靜默空資料,很難聯想到時序問題。

做法:「一次性抓取 + 快取」的 component 一律實作 `ISceneStart.EnterSceneStart()`,不要用 `Start()`
(`AbstractDescriptionBehaviour.Start()` 本身就標了 `//FIXME: 不該用這個?`)。前提同樣是該 component 要在有
`MonoObj` 的子樹下(見坑 1)。

## 更新介面

所有介面定義於 `MonoFSM/1_MonoFSM_Core/Runtime/LifeCycle/Update/Simulate/IUpdateSimulate.cs`。

| 介面 | 方法 | 時機 | 用途 |
|------|------|------|------|
| `IBeforeSimulate` | `BeforeSimulate(float deltaTime)` | FixedUpdate 開頭 | 輸入處理、前置計算 |
| `IUpdateSimulate` | `Simulate(float deltaTime)` | FixedUpdate 主體 | 核心模擬邏輯 |
| `IAfterSimulate` | `AfterSimulate(float deltaTime)` | FixedUpdate 尾段 | 後處理、同步 |
| `IRenderUpdate` | `Render(float runnerLocalRenderTime)` | Local LateUpdate / Fusion Render | 視覺更新、插值、動畫;不吃 `ShouldSimulte` authority gate |
| `IAfterRenderMono` | `AfterRender()` | Fusion AfterRender / local render 尾段 | 必須晚於一般 Render 的視覺收尾 |

## 實作模式

實作任一介面並掛在 MonoObj 子物件上,會被 `[AutoChildren]` 自動收集。

```csharp
public class MyVisualUpdater : MonoBehaviour, IRenderUpdate
{
    public void Render(float deltaTime)
    {
        // 視覺插值、動畫更新等
    }
}
```

```csharp
public class MySimulator : MonoBehaviour, IUpdateSimulate
{
    public void Simulate(float deltaTime)
    {
        // 核心模擬邏輯
    }

    // 可選:控制執行順序(數字越小越先)
    public int SimulateOrder => 10;
}
```

## 關鍵檔案

| 檔案 | 職責 |
|------|------|
| `WorldUpdateSimulator.cs` | 世界更新中心,管理所有 MonoObj 的註冊與每幀迭代 |
| `LocalSimulatorRunner.cs` | 本地模式的 Runner,驅動 FixedUpdate/LateUpdate |
| `MonoObj.cs` | 持有各階段介面陣列,轉發更新呼叫 |
| `IUpdateSimulate.cs` | 所有更新介面定義 |

## Culling phase gate

`MonoObj` 支援三種 handle,三者都由自己 scope 內的 `[AutoChildren(StopAtType = MonoObj)]`
自動收集:

| Handle | 停止的 phase | 用途 |

From RED-CANDLE-GAMES-CO-LTD/MonoFSM, MIT.

More from RED-CANDLE-GAMES-CO-LTD/MonoFSM

Signals

Stars
25
Forks
2
Open issues
49
Last commit (this folder)
Oct 5, 2026 (28 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from RED-CANDLE-GAMES-CO-LTD

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get MonoObjLifecycle running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying MonoObjLifecycle?

CallGet help
Cite this page

MonoObjLifecycle skill. Agent Mart. https://agentmart.dev/skills/red-candle-games-co-ltd-monoobjlifecycle (last updated 2026-10-24)