Ryan Green
Ryan Green7mo ago

'Networking.NetworkSpawnerModel' is missing the class attribute

I'm receiving the following exception after compile: 'Networking.NetworkSpawnerModel' is missing the class attribute 'ExtensionOfNativeClass'!
[RealtimeModel]
public partial class NetworkSpawnerModel
{
[RealtimeProperty(1, true, true)]
private bool _active;
}

public class NetworkSpawner : RealtimeComponent<NetworkSpawnerModel>

...
[RealtimeModel]
public partial class NetworkSpawnerModel
{
[RealtimeProperty(1, true, true)]
private bool _active;
}

public class NetworkSpawner : RealtimeComponent<NetworkSpawnerModel>

...
is there a way to get rid of this error?
4 Replies
kapa.ai
kapa.ai7mo ago
Hi @Ryan Green | MONA. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error you're encountering seems to be related to the way you've defined your RealtimeModel. In Normcore, a RealtimeModel represents a collection of states to synchronize and it should be a partial class. Your NetworkSpawnerModel class should look like this:
[RealtimeModel]
public partial class NetworkSpawnerModel
{
[RealtimeProperty(1, true, true)]
private bool _active;
}
[RealtimeModel]
public partial class NetworkSpawnerModel
{
[RealtimeProperty(1, true, true)]
private bool _active;
}
Also, 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. If you're using Unity 2021 or newer, Normcore will automatically generate the remaining code needed to use your model. The extra code exists as temporary C# code generated when your project compiles. If you're still encountering issues, you might want to check the official Normcore documentation (https://normcore.io/documentation/realtime/synchronizing-custom-data#generating-model-code-in-unity-2021) or consider upgrading to Normcore 2 if you're currently working with Normcore 1. Normcore 2 is designed to be a clean upgrade that requires no changes for most projects and has improved significantly in terms of transform syncing, voice chat, and overall latency. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai7mo ago
<@337874773742845953> kapa.ai is still learning and improving, please let us know how it did by reacting below
Ryan Green
Ryan GreenOP7mo ago
@maxweisel is this something you've seen before? aha, nm. moving the model definition into its own file fixed it
maxweisel
maxweisel7mo ago
glad you got it sorted!