@@ -291,7 +291,7 @@ internal void OnValidate()
291291 if ( GlobalObjectIdHash != oldValue )
292292 {
293293 // Check if this is an in-scnee placed NetworkObject (Special Case for In-Scene Placed).
294- if ( IsSceneObject . HasValue && IsSceneObject . Value )
294+ if ( InScenePlaced )
295295 {
296296 // Sanity check to make sure this is a scene placed object.
297297 if ( globalId . identifierType != k_SceneObjectType )
@@ -340,7 +340,12 @@ private void CheckForInScenePlaced()
340340 EditorUtility . SetDirty ( this ) ;
341341 }
342342 }
343- IsSceneObject = true ;
343+
344+ #pragma warning disable CS0618 // Type or member is obsolete
345+ // Obsolete with warning means we need the underlying behaviour to keep existing
346+ // TODO-3.x: remove in the 3.x branch
347+ SetSceneObjectStatus ( true ) ;
348+ #pragma warning restore CS0618 // Type or member is obsolete
344349
345350 // Default scene migration synchronization to false for in-scene placed NetworkObjects
346351 SceneMigrationSynchronization = false ;
@@ -1225,15 +1230,24 @@ private bool InternalHasAuthority()
12251230 public bool IsSpawned { get ; internal set ; }
12261231
12271232 /// <summary>
1228- /// Gets if the object is a SceneObject, null if it's not yet spawned but is a scene object .
1233+ /// Gets if the object is a SceneObject.
12291234 /// </summary>
1235+ [ Obsolete ( "Use InScenePlaced instead" ) ]
12301236 public bool ? IsSceneObject { get ; internal set ; }
12311237
1232- //DANGOEXP TODO: Determine if we want to keep this
1238+ /// <summary>
1239+ /// True if this object is placed in a scene; false otherwise.
1240+ /// </summary>
1241+ [ field: HideInInspector ]
1242+ [ field: SerializeField ]
1243+ public bool InScenePlaced { get ; internal set ; }
1244+
12331245 /// <summary>
12341246 /// Sets whether this NetworkObject was instantiated as part of a scene
12351247 /// </summary>
1248+ /// <remarks>Only use this when using custom scene loading</remarks>
12361249 /// <param name="isSceneObject">When true, marks this as a scene-instantiated object; when false, marks it as runtime-instantiated</param>
1250+ [ Obsolete ( "SetSceneObjectStatus is now calculated during the build." ) ]
12371251 public void SetSceneObjectStatus ( bool isSceneObject = false )
12381252 {
12391253 IsSceneObject = isSceneObject ;
@@ -1457,7 +1471,7 @@ internal Scene SceneOrigin
14571471 /// </summary>
14581472 internal NetworkSceneHandle GetSceneOriginHandle ( )
14591473 {
1460- if ( SceneOriginHandle . IsEmpty ( ) && IsSpawned && IsSceneObject != false )
1474+ if ( SceneOriginHandle . IsEmpty ( ) && IsSpawned && InScenePlaced )
14611475 {
14621476 if ( NetworkManager . LogLevel <= LogLevel . Error )
14631477 {
@@ -1622,7 +1636,7 @@ public void NetworkHide(ulong clientId)
16221636 var message = new DestroyObjectMessage
16231637 {
16241638 NetworkObjectId = NetworkObjectId ,
1625- DestroyGameObject = ! IsSceneObject . Value ,
1639+ DestroyGameObject = ! InScenePlaced ,
16261640 IsDistributedAuthority = NetworkManagerOwner . DistributedAuthorityMode ,
16271641 IsTargetedDestroy = NetworkManagerOwner . DistributedAuthorityMode ,
16281642 TargetClientId = clientId , // Just always populate this value whether we write it or not
@@ -1752,7 +1766,7 @@ private void OnDestroy()
17521766 var isStillValid = gameObject != null && gameObject . scene . IsValid ( ) && gameObject . scene . isLoaded ;
17531767
17541768 // If we're not the authority and everything is valid and dynamically spawned, then the destroy is not valid.
1755- if ( ! isAuthorityDestroy && IsSceneObject == false && isStillValid )
1769+ if ( ! isAuthorityDestroy && ! InScenePlaced && isStillValid )
17561770 {
17571771 if ( networkManager . LogLevel <= LogLevel . Error )
17581772 {
@@ -1851,7 +1865,7 @@ internal void SpawnInternal(bool destroyWithScene, ulong ownerClientId, bool pla
18511865 }
18521866 }
18531867
1854- if ( ! NetworkManagerOwner . SpawnManager . AuthorityLocalSpawn ( this , NetworkManagerOwner . SpawnManager . GetNetworkObjectId ( ) , IsSceneObject . HasValue && IsSceneObject . Value , playerObject , ownerClientId , destroyWithScene ) )
1868+ if ( ! NetworkManagerOwner . SpawnManager . AuthorityLocalSpawn ( this , NetworkManagerOwner . SpawnManager . GetNetworkObjectId ( ) , InScenePlaced , playerObject , ownerClientId , destroyWithScene ) )
18551869 {
18561870 if ( NetworkManagerOwner . LogLevel <= LogLevel . Normal )
18571871 {
@@ -2534,8 +2548,7 @@ internal bool ApplyNetworkParenting(bool removeParent = false, bool ignoreNotSpa
25342548 // Handle the first in-scene placed NetworkObject parenting scenarios. Once the m_LatestParent
25352549 // has been set, this will not be entered into again (i.e. the later code will be invoked and
25362550 // users will get notifications when the parent changes).
2537- var isInScenePlaced = IsSceneObject . HasValue && IsSceneObject . Value ;
2538- if ( transform . parent != null && ! removeParent && ! m_LatestParent . HasValue && isInScenePlaced )
2551+ if ( transform . parent != null && ! removeParent && ! m_LatestParent . HasValue && InScenePlaced )
25392552 {
25402553 var parentNetworkObject = transform . parent . GetComponent < NetworkObject > ( ) ;
25412554
@@ -3277,7 +3290,7 @@ internal SerializedObject Serialize(ulong targetClientId = NetworkManager.Server
32773290 NetworkObjectId = NetworkObjectId ,
32783291 OwnerClientId = OwnerClientId ,
32793292 IsPlayerObject = IsPlayerObject ,
3280- IsSceneObject = IsSceneObject ?? true ,
3293+ IsSceneObject = InScenePlaced ,
32813294 DestroyWithScene = DestroyWithScene ,
32823295 DontDestroyWithOwner = DontDestroyWithOwner ,
32833296 HasOwnershipFlags = NetworkManagerOwner . DistributedAuthorityMode ,
@@ -3462,7 +3475,7 @@ internal void SubscribeToActiveSceneForSynch()
34623475 {
34633476 if ( ActiveSceneSynchronization )
34643477 {
3465- if ( IsSceneObject . HasValue && ! IsSceneObject . Value )
3478+ if ( ! InScenePlaced )
34663479 {
34673480 // Just in case it is a recycled NetworkObject, unsubscribe first
34683481 SceneManager . activeSceneChanged -= CurrentlyActiveSceneChanged ;
@@ -3479,7 +3492,7 @@ private void CurrentlyActiveSceneChanged(Scene current, Scene next)
34793492 {
34803493 // Early exit if the NetworkObject is not spawned, is an in-scene placed NetworkObject,
34813494 // or the NetworkManager is shutting down.
3482- if ( ! IsSpawned || IsSceneObject != false || NetworkManagerOwner . ShutdownInProgress )
3495+ if ( ! IsSpawned || NetworkManagerOwner . ShutdownInProgress || InScenePlaced )
34833496 {
34843497 return ;
34853498 }
@@ -3489,7 +3502,7 @@ private void CurrentlyActiveSceneChanged(Scene current, Scene next)
34893502 {
34903503 // Only dynamically spawned NetworkObjects that are not already in the newly assigned active scene will migrate
34913504 // and update their scene handles
3492- if ( IsSceneObject . HasValue && ! IsSceneObject . Value && gameObject . scene != next && gameObject . transform . parent == null )
3505+ if ( gameObject . scene != next && gameObject . transform . parent == null )
34933506 {
34943507 SceneManager . MoveGameObjectToScene ( gameObject , next ) ;
34953508 SceneChangedUpdate ( next ) ;
@@ -3577,7 +3590,7 @@ internal bool UpdateForSceneChanges()
35773590 // the NetworkManager is shutting down, the NetworkObject is not spawned, it is an in-scene placed
35783591 // NetworkObject, or the GameObject's current scene handle is the same as the SceneOriginHandle
35793592 if ( ! SceneMigrationSynchronization || ! IsSpawned || NetworkManagerOwner . ShutdownInProgress ||
3580- ! NetworkManagerOwner . NetworkConfig . EnableSceneManagement || IsSceneObject != false || ! gameObject )
3593+ ! NetworkManagerOwner . NetworkConfig . EnableSceneManagement || InScenePlaced || ! gameObject )
35813594 {
35823595 // Stop checking for a scene migration
35833596 return false ;
@@ -3612,15 +3625,15 @@ internal uint CheckForGlobalObjectIdHashOverride()
36123625
36133626 // If scene management is disabled and this is an in-scene placed NetworkObject then go ahead
36143627 // and send the InScenePlacedSourcePrefab's GlobalObjectIdHash value (i.e. what to dynamically spawn)
3615- if ( ! networkManager . NetworkConfig . EnableSceneManagement && IsSceneObject . Value && InScenePlacedSourceGlobalObjectIdHash != 0 )
3628+ if ( ! networkManager . NetworkConfig . EnableSceneManagement && InScenePlaced && InScenePlacedSourceGlobalObjectIdHash != 0 )
36163629 {
36173630 return InScenePlacedSourceGlobalObjectIdHash ;
36183631 }
36193632
36203633 // If the PrefabGlobalObjectIdHash is a non-zero value and the GlobalObjectIdHash value is
36213634 // different from the PrefabGlobalObjectIdHash value, then the NetworkObject instance is
36223635 // an override for the original network prefab (i.e. PrefabGlobalObjectIdHash)
3623- if ( ! IsSceneObject . Value && GlobalObjectIdHash != PrefabGlobalObjectIdHash )
3636+ if ( ! InScenePlaced && GlobalObjectIdHash != PrefabGlobalObjectIdHash )
36243637 {
36253638 // If the PrefabGlobalObjectIdHash is already populated (i.e. InstantiateAndSpawn used), then return this
36263639 if ( PrefabGlobalObjectIdHash != 0 )
0 commit comments