Force Event firing
What property do we set to force event firing if the model is updated but not changed?
6 Replies
Hi @cryptomax. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To force event firing when a model property is updated but not changed in NormalVR, you can set the
includeEqualityCheck
argument of the RealtimeProperty
attribute to false
.
This is explained in the Supported Primitives (https://normcore.io/documentation/room/supported-primitives) documentation:
By setting includeEqualityCheck: false
, Normcore will mark the property to be serialized and sent to all players every time the setter is called, regardless of whether the value has actually changed. This is useful in scenarios where you need to ensure the update is propagated even if the value remains the same.
It's important to note that this setting should be used judiciously, as it can increase network traffic. It's particularly useful for properties like byte arrays where the contents might change but the reference remains the same.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@401986039964631060> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai can that be added to a model after the model is created? Meaning does the auto generated normcore code need to get updated in order for that to work?
Let me check the knowledge base for you again. One moment! :books:
----------------------
Yes, you can add or modify the
includeEqualityCheck
parameter for a RealtimeProperty
after the model has been created. However, this change does require the auto-generated Normcore code to be updated. Here's how it works depending on your Unity version:
1. For Unity 2021 or newer:
The auto-generated code is automatically updated when you make changes to your model class. As mentioned in the RealtimeModel documentation (https://normcore.io/documentation/room/realtimemodel#compiling-a-model), "If you're using Unity 2021 or newer, Normcore will automatically generate the remaining code needed to use your model." So, you just need to modify the RealtimeProperty
attribute, and the changes will be reflected in the temporary C# code generated during project compilation.
2. For Unity 2019/2020:
If you're using an older version of Unity, you'll need to manually recompile the model after making changes. The documentation (https://normcore.io/documentation/room/realtimemodel#compiling-a-model) states: "If you're using an older version of Unity, you will need to manually compile the model in the Unity editor by highlighting the class and clicking 'Compile Model.'"
When modifying an existing property, follow these steps to ensure smooth compilation:
1. Start with a state where your project compiles successfully.
2. Add the includeEqualityCheck: false
parameter to the RealtimeProperty
attribute of the desired property.
3. If using Unity 2019/2020, recompile the model by selecting the model file in the Unity editor and clicking "Compile Model" in the inspector.
It's important to note that changing this parameter doesn't affect the property's ID or type, so it won't break compatibility with existing data or older versions of your application.
Remember, while this feature is useful, use it judiciously as it can increase network traffic. Only set includeEqualityCheck
to false
for properties where you need to ensure updates are always propagated, even when the value hasn't changed.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@401986039964631060> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
This answer is wrong, it needs to be done before you build. You can't change this at runtime.
I guess it kind of implies that by saying you need to recompile the model, but I assume you were asking if it can be switched at runtime