You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SetInScenePlaced marks runtime instantiated NetworkObjects as InScenePlaced #4118
A clear and concise description of what the bug is.
Reproduce Steps
Go to 'NGO_Setup'
Start play mode
Click on 'Start Host'
Click on the keyboard button "L" to load an additive scene with a spawner object
Console prints instance InScenePlaced state as False
Click on the keyboard button "D" to print current state of spawned object
Console prints instance InScenePlaced state as True
Expected Outcome
Network objects instantiated during runtime should not be marked as InScenePlaced = true.
Before the introduction of SetInScenePlaced it was allowed to instantiate network objects from Awake.
changed the title [-]SetInScenePlaced marks spawned NetworkObjects as InScenePlaced[/-][+]SetInScenePlaced marks runtime instantiated NetworkObjects as InScenePlaced[/+]on Aug 6, 2026
Thank you for your submission and the replication project as it greatly helped me narrow down the issue.
If you dynamically instantiate something and then immediately disable the root GameObject, in order for any netcode related property to be accurate you will need to make sure:
The root GameObject is active in the hierarchy.
The NetworkObject has been spawned.
Make this adjustment in your FooSpawner:
privatevoidUpdate(){if(Keyboard.current.dKey.wasPressedThisFrame){// Enable it._instance.gameObject.SetActive(true);// Spawn it. _instance.GetComponent<NetworkObject>().Spawn();// Log the netcode fields or properties you want to checkDebug.Log($"{_instance.name} now has in-scene-placed value of: {_instance.GetComponent<NetworkObject>().InScenePlaced}");}}
The related values of things that could be calculated during the spawn process are most likely not going to be accurate until it is spawned. The in-scene placed flag you are seeing when it is still disabled and not spawned lets us know you have pre-instantiated something into a scene, that is most likely still loading, and that (along with other information) allows us to determine that it should be treated as a dynamically spawned object. Once it is spawned, it should reflect the correct values.
Just to clarify our use-case.
We have our own pooling implementation with NGO. We are seeing this, when we pre-warm our pools that are constructed before the IProcessSceneWithReport.OnProcessScene is invoked, but when the scene has been loaded.
I haven't tried the suggested solution, but it seems to set the instances as active and spawns them? I guess they aren't ready for being spawned, since they are already marked as spawned?
We have currently solved it by delaying the creation of them, or by providing a separate scene for inactive instances.
To explain what is going on here. We updated the marker of whether or not an object is "in the scene" from a nullable boolean to a boolean. The previous nullable boolean wasn't calculated until the object was first spawned which meant some of the edge case handling of "in scene placed" objects was inaccurate. That inaccuracy is why the SetInScenePlaced() function existed.
As you've noticed, we moved the calculation from when the object is spawned to the IProcessSceneWithReport.OnProcessScene. The issue is, in the editor only, OnProcessScene will run after Awake has run on all objects in the scene. We were able to add checks to ensure we don't process any disabled object that is created in Awake. We also are able to skip any object that is created in a different scene and then moved into the current scene being processed.
We're talking with the build team about providing a similar callback that doesn't run Awake first in the editor. They are working on it, but the CoreCLR related build changes are taking precedence at this time.
We would be open to adding an equivalent to SetInScenePlaced that simply marks an object to be skipped by the OnProcessScene post-processor? We made this change hoping that manual configuration on the InScenePlaced variable wouldn't be needed. If it is needed then there's no reason to not add it back in.
It is a bit of a hassle, since it introduces issues in the editor that isn't immediately evident about why it happens. It requires a bit of digging into the code to find the culprit.
However, we just have to be aware that we aren't allowed to do any instantiation of network objects in Awake right after the scene has loaded.
Also, we don't call Spawn() on them, since they aren't in use at that moment. The issue is that, due to IProcessSceneWithReport.OnProcessScene setting InScenePlaced to true, we get a series of despawn ids on the clients when they connect to the host, which throws warnings.
Ok, thank you for the further information. Would it be useful to you to have a replacement for SetInScenePlaced(false) to be able to run this code in Awake? Or is moving the code a good enough solution for your use-case?
@ffejlersen
There is an update coming soon (v2.13.2) which should resolve this issue:
When creating network prefab instances at runtime prior to starting a session will now be spawned as such (i.e. dynamic) and will not be spawned as in-scene placed. (#4093) Note about this: When not spawned, network prefab instances created prior to starting a NetworkManager/session could show InScenePlaced as "true" when not spawned (initially), but upon being spawned NGO figures out that it is really "a network prefab instance instantiated before it started" and dynamically spawns it.
This issue has been automatically marked as stale because it has been awaiting response for over 2 weeks without any activity.
Please update the issue with any new information or it may be closed in 2 weeks.
Activity
[-]SetInScenePlaced marks spawned NetworkObjects as InScenePlaced[/-][+]SetInScenePlaced marks runtime instantiated NetworkObjects as InScenePlaced[/+]NoelStephensUnity commentedon Aug 7, 2026
Hi @ffejlersen,
Thank you for your submission and the replication project as it greatly helped me narrow down the issue.
If you dynamically instantiate something and then immediately disable the root GameObject, in order for any netcode related property to be accurate you will need to make sure:
Make this adjustment in your FooSpawner:
The related values of things that could be calculated during the spawn process are most likely not going to be accurate until it is spawned. The in-scene placed flag you are seeing when it is still disabled and not spawned lets us know you have pre-instantiated something into a scene, that is most likely still loading, and that (along with other information) allows us to determine that it should be treated as a dynamically spawned object. Once it is spawned, it should reflect the correct values.
Let me know if this resolves your issue?
ffejlersen commentedon Aug 11, 2026
Just to clarify our use-case.
We have our own pooling implementation with NGO. We are seeing this, when we pre-warm our pools that are constructed before the
IProcessSceneWithReport.OnProcessSceneis invoked, but when the scene has been loaded.I haven't tried the suggested solution, but it seems to set the instances as active and spawns them? I guess they aren't ready for being spawned, since they are already marked as spawned?
We have currently solved it by delaying the creation of them, or by providing a separate scene for inactive instances.
EmandM commentedon Aug 11, 2026
Delaying the creation is a solid solution here.
To explain what is going on here. We updated the marker of whether or not an object is "in the scene" from a nullable boolean to a boolean. The previous nullable boolean wasn't calculated until the object was first spawned which meant some of the edge case handling of "in scene placed" objects was inaccurate. That inaccuracy is why the
SetInScenePlaced()function existed.As you've noticed, we moved the calculation from when the object is spawned to the
IProcessSceneWithReport.OnProcessScene. The issue is, in the editor only,OnProcessScenewill run afterAwakehas run on all objects in the scene. We were able to add checks to ensure we don't process any disabled object that is created inAwake. We also are able to skip any object that is created in a different scene and then moved into the current scene being processed.We're talking with the build team about providing a similar callback that doesn't run Awake first in the editor. They are working on it, but the CoreCLR related build changes are taking precedence at this time.
We would be open to adding an equivalent to
SetInScenePlacedthat simply marks an object to be skipped by theOnProcessScenepost-processor? We made this change hoping that manual configuration on the InScenePlaced variable wouldn't be needed. If it is needed then there's no reason to not add it back in.ffejlersen commentedon Aug 14, 2026
It is a bit of a hassle, since it introduces issues in the editor that isn't immediately evident about why it happens. It requires a bit of digging into the code to find the culprit.
However, we just have to be aware that we aren't allowed to do any instantiation of network objects in Awake right after the scene has loaded.
2 remaining items
ffejlersen commentedon Aug 17, 2026
Reference back to my prior answer:
#4118 (comment)
Also, we don't call Spawn() on them, since they aren't in use at that moment. The issue is that, due to
IProcessSceneWithReport.OnProcessScenesettingInScenePlacedtotrue, we get a series of despawn ids on the clients when they connect to the host, which throws warnings.EmandM commentedon Aug 17, 2026
Ok, thank you for the further information. Would it be useful to you to have a replacement for
SetInScenePlaced(false)to be able to run this code in Awake? Or is moving the code a good enough solution for your use-case?NoelStephensUnity commentedon Aug 19, 2026
@ffejlersen
There is an update coming soon (v2.13.2) which should resolve this issue:
When creating network prefab instances at runtime prior to starting a session will now be spawned as such (i.e. dynamic) and will not be spawned as in-scene placed. (#4093)
Note about this:
When not spawned, network prefab instances created prior to starting a NetworkManager/session could show InScenePlaced as "true" when not spawned (initially), but upon being spawned NGO figures out that it is really "a network prefab instance instantiated before it started" and dynamically spawns it.
github-actions commentedon Sep 3, 2026
This issue has been automatically marked as stale because it has been awaiting response for over 2 weeks without any activity.
Please update the issue with any new information or it may be closed in 2 weeks.