foundrey
foundrey3mo ago

Failed to set model on Component still erroring after working through checklist

I have been working fine with normcore for sometime and have become accustomed to creating RealtimeComponents with models in the appropriate pattern, but recently: I created a new realtime component called CustomizationManager which has a model CustomizationInfoModel Since adding it to my realtime object: All the components under the parent view are throwing: Failed to set model on component Errors. Checklist: - Checked if the realtime.instantiate call is wrong - Checked if the prefab is not in a resources folder - Checked the hierarchy to see if the component is under "deprecated components" it's not - Checked it was the right RealtimeComponent<TValue> - Removed the component and added it back - Removed the realtime view and all components and added them back - Remade a new prefab - Restarted unity - Reimported my library The problem is still persisting. The interesting thing is when I add the new component to a realtime object it first appears under "deprecated components" and only that new component (CustomizationManager) is throwing the Failed to set model on component error. Once I remove the realtime view and re-add it and the components back along with the new component (CustomizationManager), they all show up under the correct components in the inspector view but now all the realtime components with a model throw the Failed to set model on component It's like this new component is some contagion or something contaminating otherwise healthy realtimeViews haha Additional notes: - Recently updated Editor versions to Unity 6000.0.50f1 LTS - The bug started appearing after the upgrade - Haven't tried reimporting normcore itself yet
26 Replies
kapa.ai
kapa.ai3mo ago
Hi @foundrey. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on your description, it sounds like you're experiencing issues with your RealtimeComponents after upgrading Unity. This is a known issue that can occur when upgrading Unity versions while using Normcore. The error "Failed to set model on component" typically occurs when Normcore can't properly initialize the model for your RealtimeComponent. Since you mentioned this started happening after upgrading to Unity 6000.0.50f1 LTS, this is likely a compatibility issue between your current Normcore version and the new Unity version. Here are some potential solutions: 1. Update Normcore: The most straightforward solution would be to update Normcore to the latest version through the Package Manager. Newer versions of Normcore include fixes for compatibility with newer Unity versions. After updating, restart Unity to ensure all changes take effect Common Questions. 2. Check Model Compilation: If you're using Unity 2019/2020, make sure your models are properly compiled. For Unity 2021+, model compilation should happen automatically Generating model code in Unity 2019/2020. 3. Verify RealtimeModel Attributes: Ensure your CustomizationInfoModel has the proper [RealtimeModel] attribute and that all properties have the correct [RealtimeProperty] attributes Creating a realtime model. 4. Check Meta-Model: If your component uses ownership, make sure your model includes a meta-model by adding createMetaModel: true to the RealtimeModel attribute Requesting ownership of any RealtimeComponent or RealtimeModel. 5. Reimport Normcore: Since you haven't tried this yet, it might be worth completely reimporting Normcore. This can resolve issues where Unity's upgrade process might have corrupted some Normcore files. 6. Check for Compilation Errors: Make sure your project has no compilation errors. If your project has any errors, any changes you make to the model will not be visible to the model editor Common Questions. The fact that your new component initially appears under "deprecated components" suggests there might be an issue with how the component is being registered with the RealtimeView. This could be related to the Unity upgrade process affecting how Normcore's editor scripts function. If none of these solutions work, you might want to consider creating a clean project with the latest Normcore version and your current Unity version to test if the issue persists in a fresh environment. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@719968242445058051> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
maxweisel
maxweisel3mo ago
Whenever this happens, Normcore will log the reason it failed to add the component. Are you getting any other errors or warnings?
foundrey
foundreyOP3mo ago
Yeah that's the interesting thing I don't see any at the moment: Here's the full trace for the two components erroring (attached below): Other than that I have the standard NullReferenceExceptions for OnRealtimeModelReplaced for each which makes sense considering there is no model. Component #2 is a realtimeTransform so it's getting initialized fine or wouldn't throw the same kind of error.
foundrey
foundreyOP3mo ago
foundrey
foundreyOP3mo ago
We're connecting to the room and I'm successfully instantiating other realtime objects I haven't added this component to before Could definitely be a mistake I'm making in the serialization process or something wrong with my environment considering we just upgraded. Just definitely something I've never encountered before
maxweisel
maxweisel3mo ago
I think this might be a known bug in RealtimeView’s management of child components. We have a fix shipping soon. In the meantime, if you use the Debug Inspector to clear the child view and components lists and then switch back so RealtimeView rebuilds them, does that fix it? (Note: this will break compatibility with previously shipped builds)
foundrey
foundreyOP3mo ago
No luck on the fix unfortunately. Can try putting everything under the root view just to see as well. Throwing the same errors in sequence
maxweisel
maxweisel3mo ago
hmm, what's the stack trace on the null ref exception error log?
foundrey
foundreyOP3mo ago
Wait let me put that in a txt jesus hahaha
maxweisel
maxweisel3mo ago
Can you show me the implementation of your OnRealtimeModelReplaced method* from VehicleCustomizationManager?
foundrey
foundreyOP3mo ago
For sure one sec
maxweisel
maxweisel3mo ago
can you tell me which line is line 96? oh I see the bug you're operating on previousModel within your if (currentModel != null) block I think that should be currentModel.parts.modelAdded +=
foundrey
foundreyOP3mo ago
previousModel.parts.modelAdded += OnPartAdded;
maxweisel
maxweisel3mo ago
yes previousModel is null the first time this method is called because there's no previous model yet
foundrey
foundreyOP3mo ago
ohhhhhhhhh shit lol hahaha just realized that what a stupid goof lol
maxweisel
maxweisel3mo ago
all good. glad it was an easy fix
foundrey
foundreyOP3mo ago
you think that could also affect the serialization process because it's a mandatory implementation? that would make sense tbh
maxweisel
maxweisel3mo ago
yes
foundrey
foundreyOP3mo ago
sweet seems to have cleared the error for one of the components The other (different component) I'm erroring the same: NullReferenceException: Object reference not set to an instance of an object GetSetGo.Netcode.Normal.Components.Driving.NormalVehicle.OnRealtimeModelReplaced (VehicleModel previousModel, VehicleModel currentModel) (at Assets/GetSetGo/Netcode/Normal/Components/Driving/NormalVehicle.cs:118) Normal.Realtime.RealtimeComponent1[TModel].Normal.Realtime.IConfigurableComponent.SetModel (Normal.Realtime.RealtimeModel model) (at <60e132fa77ae45deb6e21a954df3ec41>:0) Normal.Realtime.RealtimeView.BindModelsToComponentMap (Normal.Realtime.ImmutableModelCollection models, Normal.Realtime.RealtimeComponentMap components) (at <60e132fa77ae45deb6e21a954df3ec41>:0) UnityEngine.Debug:LogException(Exception) Normal.Realtime.RealtimeView:BindModelsToComponentMap(ImmutableModelCollection, RealtimeComponentMap) Normal.Realtime.RealtimeView:Normal.Realtime.IConfigurableComponent.SetModel(RealtimeModel) Normal.Realtime.RealtimeView:InstantiateViewPrefab(RealtimeViewModel, Realtime) Normal.Realtime.Realtime:CreatePrefabForRealtimeViewModel(RealtimeViewModel) Normal.Realtime.Realtime:PrefabRealtimeViewModelAdded(Datastore, RealtimeViewModel, Boolean) Normal.Realtime.Datastore:PrefabViewModelAddedToSet(RealtimeSet1, RealtimeViewModel, Boolean) Normal.Realtime.Serialization.RealtimeSet1:SafeDispatchModelAdded(RealtimeViewModel, Boolean) Normal.Realtime.Serialization.RealtimeSet1:Add(RealtimeViewModel) Normal.Realtime.Datastore:AddPrefabRealtimeViewModel(RealtimeViewModel) Normal.Realtime.Realtime:InstantiateInternal(String, Boolean, Boolean, Boolean, Boolean, Boolean) Normal.Realtime.Realtime:Instantiate(String, Nullable1) Normal.Realtime.Realtime:Instantiate(String, Vector3, Quaternion, Nullable1) except this line is: "realtimeTransform.ownerIDSelfDidChange += OnTransformOwnerDidChange;" in:
foundrey
foundreyOP3mo ago
which is weird because I hadn't changed this at all and wasn't erroring prior.. evidently my implementation is off in some fundamental way which is on me I guess I'm just confused how it started erroring only now 😅
maxweisel
maxweisel3mo ago
it’s not guaranteed that other components will exist or have models by the time OnRealtimeModelReplaced is called. you shouldn’t use this method to perform application logic it should be data only
foundrey
foundreyOP3mo ago
Gotcha appreciate the notice! Was under the impression that the model was the last thing to get initialized in the execution order but reading back the docs you guys make it pretty clear it's not synchronous. Thanks for the help!

Did you find this page helpful?