Skip to content

@modoki/engine / index / deriveInstanceMemberGuids

Function: deriveInstanceMemberGuids()

deriveInstanceMemberGuids(world): void

Give prefab-instance MEMBERS a stable, addressable GUID.

Prefab templates clear member GUIDs (so two instances don't collide), so a freshly-expanded member has none — nothing outside the instance can reference it. Here we derive one deterministically from the nearest scene-anchored ancestor's GUID + the chain of prefab-member localIds down to the member. Same scene → same id every load (no need to serialize it); different instances anchor on different root GUIDs, so members stay unique. Only fills EMPTY guids — a scene-assigned guid (e.g. the instance root) is never overwritten.

Anchoring uses a snapshot of guids taken BEFORE deriving, so the result is independent of iteration order (derived guids never become anchors).

Parameters

world

World

Returns

void

Built with Modoki.