cryptomax
cryptomax3mo ago

'RealtimeComponent has been replaced with RealtimeComponent<TModel>. Please upgrade

If i 'm getting this message on a script what features am I missing particularly on the mode?
11 Replies
kapa.ai
kapa.ai3mo ago
Hi @cryptomax. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- This error message indicates that you're using an older version of Normcore and need to update your script to use the newer RealtimeComponent<TModel> class. The main difference is in how the model is handled. With the newer RealtimeComponent<TModel>, you get the following benefits: 1. Type-safe access to your model: The TModel generic parameter ensures you're working with the correct model type. 2. Automatic model property: You get a built-in model property of the correct type, which you can use to access your synchronized data RealtimeComponent documentation (https://normcore.io/documentation/reference/classes/Normal.Realtime.RealtimeComponent%601). 3. OnRealtimeModelReplaced method: This method is called when the model is replaced, allowing you to set up event listeners and initialize your component based on the model's state Synchronizing Custom Data (https://normcore.io/documentation/realtime/synchronizing-custom-data#creating-a-realtimecomponent-subclass). 4. Improved performance: The newer version is optimized for better performance. To upgrade your script, you should: 1. Change your class declaration to inherit from RealtimeComponent<YourModelType> instead of just RealtimeComponent. 2. Implement the OnRealtimeModelReplaced method to set up any necessary event listeners or initialization. 3. Use the model property to access your synchronized data instead of manually managing a model property. Here's an example of how your updated script might look:
using Normal.Realtime;
public class YourComponent : RealtimeComponent<YourModelType> {
protected override void OnRealtimeModelReplaced(YourModelType previousModel, YourModelType currentModel) {
if (previousModel != null) {
// Unregister from events
previousModel.somePropertyDidChange -= SomePropertyDidChange;
}

if (currentModel != null) {
// Register for events
currentModel.somePropertyDidChange += SomePropertyDidChange;

// Initialize based on current model state
UpdateSomething();
}
}

private void SomePropertyDidChange(YourModelType model, YourPropertyType value) {
// Handle property change
UpdateSomething();
}

private void UpdateSomething() {
// Use the model property to access your data
// For example: gameObject.transform.position = model.position;
}
}
using Normal.Realtime;
public class YourComponent : RealtimeComponent<YourModelType> {
protected override void OnRealtimeModelReplaced(YourModelType previousModel, YourModelType currentModel) {
if (previousModel != null) {
// Unregister from events
previousModel.somePropertyDidChange -= SomePropertyDidChange;
}

if (currentModel != null) {
// Register for events
currentModel.somePropertyDidChange += SomePropertyDidChange;

// Initialize based on current model state
UpdateSomething();
}
}

private void SomePropertyDidChange(YourModelType model, YourPropertyType value) {
// Handle property change
UpdateSomething();
}

private void UpdateSomething() {
// Use the model property to access your data
// For example: gameObject.transform.position = model.position;
}
}
By upgrading to RealtimeComponent<TModel>, you'll have a more robust and type-safe way of working with your Normcore components. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@401986039964631060> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
cryptomax
cryptomaxOP3mo ago
@kapa.ai pre 2.0 normcore models do not support OnRealtimeModelReplaced?
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- You're correct in your observation. Pre-2.0 Normcore models indeed do not support the OnRealtimeModelReplaced method. This method was introduced as part of the improvements in Normcore 2.0. In Normcore 1.x, the RealtimeComponent class didn't have the generic type parameter and handled model replacement differently. The OnRealtimeModelReplaced method is a feature specific to Normcore 2.0 and later versions, which use the RealtimeComponent<TModel> class Upgrading from Normcore 1 to Normcore 2 (https://normcore.io/documentation/guides/upgrading-from-normcore-1-to-normcore-2). If you're still using a pre-2.0 version of Normcore, you won't have access to this method. Instead, you would typically handle model changes in a different way, often by implementing a custom setter for your model property. To take advantage of the OnRealtimeModelReplaced method and other improvements, it's recommended to upgrade to Normcore 2.0 or later. The upgrade process is designed to be relatively straightforward for most projects and brings significant improvements in transform syncing, voice chat, and overall latency Upgrading from Normcore 1 to Normcore 2 (https://normcore.io/documentation/guides/upgrading-from-normcore-1-to-normcore-2). If you decide to upgrade, you'll be able to use the more modern RealtimeComponent<TModel> class with its OnRealtimeModelReplaced method, which provides a cleaner way to handle model changes and set up event listeners Synchronizing Custom Data (https://normcore.io/documentation/realtime/synchronizing-custom-data#creating-a-realtimecomponent-subclass). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@401986039964631060> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
khoi
khoi3w ago
@kapa.ai how do i upgrade? when i click on the script, it links me to the Packages>Normcore>Normal.Realtime>2019>UnityEditor dll
kapa.ai
kapa.ai3w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To upgrade Normcore to the latest version, you'll need to update the package in Unity's Package Manager. Here's how you can do it: 1. Open your Unity project. 2. Go to Window > Package Manager in the Unity menu. 3. In the Package Manager window, make sure you're looking at "Packages" and not "My Assets". 4. Find "Normcore" in the list of packages. 5. Click on it, and you should see an option to update to the latest version. 6. After updating, restart Unity to ensure all changes take effect. It's important to note that the process you described (clicking on the script and being linked to a DLL) is not the correct way to upgrade Normcore. The DLL you're seeing is part of the currently installed version. If you're unable to see an update option in the Package Manager, you may need to update the Normal scoped registry in your project. Normcore uses a scoped registry to provide its packages Normal Scoped Registry. If you're still having trouble after trying these steps, you might want to check the official upgrade guide: Upgrading from Normcore 1 to Normcore 2. This guide provides detailed steps for upgrading, including: 1. Importing the latest Normcore 2 package 2. Deleting the old Normcore 1 files 3. Restarting Unity 4. Performing the migration Remember to always back up your project before performing any major upgrades. If you encounter any issues during the upgrade process, you can seek help from the Normcore community on their Discord server. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3w ago
<@412870643533479936> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
khoi
khoi3w ago
In the Package Manager window, make sure you're looking at "Packages" and not "My Assets". I dont think there is this tab in Unity 6.... @kapa.ai
kapa.ai
kapa.ai3w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I apologize for the confusion in my previous response. You're correct that the Package Manager interface has changed in newer versions of Unity, including Unity 2022 (which I assume you meant instead of "Unity 6", as there is no Unity 6). For the most up-to-date and accurate information on updating Normcore in your Unity project, please follow these steps: 1. Open your Unity project. 2. Go to Window > Package Manager in the Unity menu. 3. In the Package Manager window, look for Normcore in the list of installed packages. 4. If an update is available, you should see an option to update to the latest version. If you don't see Normcore listed or can't find an update option, you may need to check your project's scoped registry settings. Normcore uses a scoped registry to provide its packages Normal Scoped Registry. If you're still having trouble updating Normcore, I recommend checking the official Normcore documentation for the most current upgrade instructions, or reaching out to Normcore support through their Discord server for personalized assistance. Remember, always back up your project before performing any major upgrades. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3w ago
<@412870643533479936> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?