GreenwoodRex
GreenwoodRex2mo ago

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'.
No description
16 Replies
kapa.ai
kapa.ai2mo ago
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:
[RealtimeModel]
public partial class MyModel {
[RealtimeProperty(1, true )] private string _name;

[RealtimeProperty(2, true )] private Color _avatarPrimaryColor;
[RealtimeProperty(3, true )] private Color _avatarAlternateColor;

[RealtimeProperty(4, false)] private Vector3 _movementVelocity;
}
[RealtimeModel]
public partial class MyModel {
[RealtimeProperty(1, true )] private string _name;

[RealtimeProperty(2, true )] private Color _avatarPrimaryColor;
[RealtimeProperty(3, true )] private Color _avatarAlternateColor;

[RealtimeProperty(4, false)] private Vector3 _movementVelocity;
}
(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: ----------------------
kapa.ai
kapa.ai2mo ago
<@638425022884478997> kapa.ai is still learning and improving, please let us know how it did by reacting below
MasterOX 水
MasterOX 水2mo ago
you no longer need to press generate model, just save it and go back to unity to compile it it will do it automatically
GreenwoodRex
GreenwoodRex2mo ago
so why am i getting that error then?
MasterOX 水
MasterOX 水2mo ago
are you trying to assign the model script to an object
Mechabit
Mechabit2mo ago
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
MasterOX 水
MasterOX 水2mo ago
@GreenwoodRex ^
GreenwoodRex
GreenwoodRex2mo ago
Yes, I'm trying to assign the MyCarModel script to my car object for network synchronization. alright
MasterOX 水
MasterOX 水2mo ago
ok so you need to create a new script that references the model one second
public class ColorSync : RealtimeComponent<ColorSyncModel>
public class ColorSync : RealtimeComponent<ColorSyncModel>
like this
MasterOX 水
MasterOX 水2mo ago
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.
GreenwoodRex
GreenwoodRex2mo ago
yh i have already done this ( i think) let me show you, in case i am wrong
MasterOX 水
MasterOX 水2mo ago
okay dont assign model scripts to anything btw
GreenwoodRex
GreenwoodRex2mo ago
No description
MasterOX 水
MasterOX 水2mo ago
yeah looks good just dont assign the model script to anything
GreenwoodRex
GreenwoodRex2mo ago
oh ok got that thanks