khoi
NNormal
•Created by khoi on 2/8/2025 in #🤝ask-a-question
RealtimeComponent has been replaced with RealtimeComponent<TModel>
@kapa.ai 1. I am using Realtime Instantiate. RealtimeView component shows the ActiveStateSync on my prefab. 2. RealtimeView shows the ActiveStateSync component in its components list.
My logic is in OnRealtimeModelReplaced
I spawn the prefab after didConnectToRoom fires.
I am spawning it with ownedByClient true
I added createMetaModel true
Still not working. Here is my code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RealtimeModel(createMetaModel: true)]
public partial class ActiveStateModel
{
[RealtimeProperty(1, true, true)]
private bool _isActive;
}
using UnityEngine;
using Normal.Realtime;
public class ActiveStateSync : RealtimeComponent<ActiveStateModel>
{
protected override void OnRealtimeModelReplaced(ActiveStateModel previousModel, ActiveStateModel currentModel)
{
if (previousModel != null)
{
previousModel.isActiveDidChange -= ActiveStateChanged;
}
if (currentModel != null)
{
if (currentModel.isFreshModel)
currentModel.isActive = false;
UpdateActiveState();
currentModel.isActiveDidChange += ActiveStateChanged;
}
}
private void ActiveStateChanged(ActiveStateModel model, bool value)
{
UpdateActiveState();
}
private void UpdateActiveState()
{
gameObject.SetActive(model.isActive);
}
public void SetActive(bool active)
{
model.isActive = active;
}
}
private System.Collections.IEnumerator RespawnComboBagCoroutine()
{
GameObject newBag = Realtime.Instantiate("ComboBag112 Variant", ownedByClient: true);
newBag.GetComponent<ActiveStateSync>().SetActive(false);
yield return new WaitForSeconds(3f);
newBag.GetComponent<ActiveStateSync>().SetActive(true);
}
Could there be an issue with calling the SetActive from an IEnumerator?
20 replies
NNormal
•Created by khoi on 2/8/2025 in #🤝ask-a-question
RealtimeComponent has been replaced with RealtimeComponent<TModel>
@kapa.ai can you read my file
20 replies
NNormal
•Created by khoi on 2/8/2025 in #🤝ask-a-question
RealtimeComponent has been replaced with RealtimeComponent<TModel>
@kapa.ai Ok. I implemented everything and there seem to be no errors. However, my object is still not being deactivated / activated when I call .GetComponent<ActiveStateSync>().SetActive(true)
20 replies
NNormal
•Created by cryptomax on 11/27/2024 in #🤝ask-a-question
'RealtimeComponent has been replaced with RealtimeComponent<TModel>. Please upgrade
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
17 replies
NNormal
•Created by cryptomax on 11/27/2024 in #🤝ask-a-question
'RealtimeComponent has been replaced with RealtimeComponent<TModel>. Please upgrade
@kapa.ai how do i upgrade? when i click on the script, it links me to the Packages>Normcore>Normal.Realtime>2019>UnityEditor dll
17 replies