Hi.
I have a GameObject call GameControllerManager which is not a prefab.
GameControllerManager use NetworkBehavior and attached NetworkObject component.
There are pause function that use on this Manager.
Receive Player Event on Pause and then use serverRpc → ClientRpc to pause all player Game.
In first level everything work normally as expected.
But when players completed the level and proceed the next level,
When player try to pause the game I got this error.
InvalidOperationException: An RPC called on a NetworkObject that is not in the spawned objects list. Please make sure the NetworkObject is spawned before calling RPCs.
What my understand is when you use In-Scene Place Object. You do not need to make a prefab and add in DefaultNetworkpPrefabs List. Which I wonder what might be the cause of this.
GameControllerManager GameObject are manually copy and paste. I tried remove and add NetworkObject in GameObject as well. In GameControllerManager have OnNetworkSpawn and prove that are running on both scene. (with Debug.log)
Any Ideas what I might done wrong?
Should I run despawn GameControllManager before changing scene?
A common issue in this scenario is that in-scene placed network objects only work in networked scenes. This is easy to overlook, for instance by not using NetworkSceneManager to load a scene after the host/server is started. In that case the loaded scene is effectively an offline scene with any in-scene placed network objects being dysfunctional.
Hi. Thank you for your reply.
I checked my code. I used NetworkSceneManager to Load the scene as follow.
nextLevelButton.onClick.AddListener(() =>
{
if (SceneManager.GetActiveScene().name == LoadingUI.Scene.MultiplayerScene01.ToString())
{
LoadingUI.LoadNetwork(LoadingUI.Scene.MultiplayerScene02);
}
else if (SceneManager.GetActiveScene().name == LoadingUI.Scene.MultiplayerScene02.ToString())
{
LoadingUI.LoadNetwork(LoadingUI.Scene.MultiplayerScene03);
}
});
public static void LoadNetwork(Scene scene)
{
NetworkManager.Singleton.SceneManager.LoadScene(scene.ToString(), LoadSceneMode.Single);
}
But it still not working.
Is there anyone got this issue?
Maybe NetCode bug?
I hope to solve this soon but I will try to think for workaround.
Got this solved now. Turn out it not GameControllerManager false.
It is Player that Publish event to GameControllerManager.
Which did not clear static data before move to other scene.