Missing Class Attributes
I'm trying to integrate Normcore into my Unity driving game. I followed the steps to create a MyCarModel class and added the [RealtimeModel] attribute. However, I'm not seeing the "Generate Realtime Model" option when I right-click on the MyCarModel.cs file. When I try to manually use the model, I get the error: 'MyCarModel' is missing the class attribute 'ExtensionOfNativeClass'.
16 Replies
Hi @GreenwoodRex. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The issue you're experiencing might be due to the version of Unity you're using. 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. You won't see it in your file, so don't worry if you don't see it (source (https://normcore.io/documentation/room/realtimemodel#compiling-a-model)).
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." It's worth noting that if any script in your project does not compile, Normcore's manual model compiler will be unable to load any of the state of your model (source (https://normcore.io/documentation/room/realtimemodel#compiling-a-model)).
Also, ensure that your model class is a
partial
class and not a subclass of any other class. Each field in the model should be a primitive type and should be private with an underscore prefix. Here's an example of how a typical RealtimeModel looks like:
(source (https://normcore.io/documentation/room/realtimemodel))
If you're still having issues, I recommend checking out the Getting Started (https://normcore.io/documentation/essentials/getting-started) guide or the Synchronizing custom data (https://normcore.io/documentation/realtime/synchronizing-custom-data) guide for a more detailed walkthrough.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@638425022884478997> kapa.ai is still learning and improving, please let us know how it did by reacting below
you no longer need to press generate model, just save it and go back to unity to compile it
it will do it automatically
so why am i getting that error then?
are you trying to assign the model script to an object
make sure your project is in a compiling state.
you use models in RealtimeComponent scripts.
if both those things don't work you can try reimporting scripts (right-click reimport your scripts folder)
if that still doesn't work try deleting the library folder
@GreenwoodRex ^
Yes, I'm trying to assign the MyCarModel script to my car object for network synchronization.
alright
ok so you need to create a new script that references the model
one second
like this
theres an example here https://normcore.io/documentation/realtime/synchronizing-custom-data
Synchronizing Custom Data | Normcore Documenation
In this guide, I’m going to walk you through how to synchronize custom data in your Unity application using custom realtime components.
yh i have already done this ( i think)
let me show you, in case i am wrong
okay
dont assign model scripts to anything btw
yeah looks good
just dont assign the model script to anything
oh ok got that
thanks
np