Mechabit
Mechabit3d ago

gameObject.SetActive(false)

If I have a realtime component on a game object and I deactivated the game object does the model update or does the game object need to remain active to send/receive model changes?
5 Replies
kapa.ai
kapa.ai3d ago
Hi @Mechabit. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The docs don’t state explicit behavior for disabling a GameObject that has a RealtimeComponent, but they do say you cannot disable a RealtimeView itself, because a disabled scene view never registers with Realtime and won’t be initialized or connected to the datastore. [RealtimeView questions] Key points we can say confidently from the docs: - Once a RealtimeComponent<TModel> has its model assigned (after OnRealtimeModelReplaced is called), that model is managed and synced by Normcore independently of your script’s Update/OnEnable etc. [RealtimeComponent; Custom data guide] - Disabling RealtimeView itself is explicitly unsupported, but disabling child objects / scripts is suggested as a pattern (“use a custom RealtimeComponent to enable/disable child game objects, scripts, or renderers directly”). [RealtimeView questions] What is not clearly documented: - Whether a disabled GameObject that already has an initialized RealtimeComponent continues to send/receive model changes automatically. The knowledge sources don’t say if Normcore internally checks gameObject.activeInHierarchy before applying model updates or serializing local changes. So, based strictly on the docs: - You must keep the RealtimeView enabled and registered with Realtime for syncing to work. - You are allowed (and even encouraged) to enable/disable child GameObjects and scripts from a RealtimeComponent to control visibility/behavior. - The docs do not explicitly guarantee that a disabled GameObject with a RealtimeComponent will continue to send/receive updates; this detail is not covered. If you need a safe pattern that’s consistent with the docs, keep the RealtimeView and its RealtimeComponent scripts enabled, and toggle only the visual/logic parts (child objects, renderers, non‑realtime scripts) rather than disabling the whole object that owns the RealtimeView. [RealtimeView questions] ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3d ago
<@162940911964258305> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
maxweisel
maxweisel3d ago
the model will still update as long as the root RealtimeView was active long enough for Start() to run
Mechabit
MechabitOP3d ago
and I can reactivate it with a model change event on the inactive gameobject?
maxweisel
maxweisel3d ago
yeah that will work

Did you find this page helpful?