@@ -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
@@ -1750,7 +1764,7 @@ private void OnDestroy()
17501764 var isStillValid = gameObject != null && gameObject . scene . IsValid ( ) && gameObject . scene . isLoaded ;
17511765
17521766 // If we're not the authority and everything is valid and dynamically spawned, then the destroy is not valid.
1753- if ( ! isAuthorityDestroy && IsSceneObject == false && isStillValid )
1767+ if ( ! isAuthorityDestroy && ! InScenePlaced && isStillValid )
17541768 {
17551769 if ( networkManager . LogLevel <= LogLevel . Error )
17561770 {
@@ -1849,7 +1863,7 @@ internal void SpawnInternal(bool destroyWithScene, ulong ownerClientId, bool pla
18491863 }
18501864 }
18511865
1852- if ( ! NetworkManagerOwner . SpawnManager . AuthorityLocalSpawn ( this , NetworkManagerOwner . SpawnManager . GetNetworkObjectId ( ) , IsSceneObject . HasValue && IsSceneObject . Value , playerObject , ownerClientId , destroyWithScene ) )
1866+ if ( ! NetworkManagerOwner . SpawnManager . AuthorityLocalSpawn ( this , NetworkManagerOwner . SpawnManager . GetNetworkObjectId ( ) , InScenePlaced , playerObject , ownerClientId , destroyWithScene ) )
18531867 {
18541868 if ( NetworkManagerOwner . LogLevel <= LogLevel . Normal )
18551869 {
@@ -2528,8 +2542,7 @@ internal bool ApplyNetworkParenting(bool removeParent = false, bool ignoreNotSpa
25282542 // Handle the first in-scene placed NetworkObject parenting scenarios. Once the m_LatestParent
25292543 // has been set, this will not be entered into again (i.e. the later code will be invoked and
25302544 // users will get notifications when the parent changes).
2531- var isInScenePlaced = IsSceneObject . HasValue && IsSceneObject . Value ;
2532- if ( transform . parent != null && ! removeParent && ! m_LatestParent . HasValue && isInScenePlaced )
2545+ if ( transform . parent != null && ! removeParent && ! m_LatestParent . HasValue && InScenePlaced )
25332546 {
25342547 var parentNetworkObject = transform . parent . GetComponent < NetworkObject > ( ) ;
25352548
@@ -3271,7 +3284,7 @@ internal SerializedObject Serialize(ulong targetClientId = NetworkManager.Server
32713284 NetworkObjectId = NetworkObjectId ,
32723285 OwnerClientId = OwnerClientId ,
32733286 IsPlayerObject = IsPlayerObject ,
3274- IsSceneObject = IsSceneObject ?? true ,
3287+ IsSceneObject = InScenePlaced ,
32753288 DestroyWithScene = DestroyWithScene ,
32763289 DontDestroyWithOwner = DontDestroyWithOwner ,
32773290 HasOwnershipFlags = NetworkManagerOwner . DistributedAuthorityMode ,
@@ -3456,7 +3469,7 @@ internal void SubscribeToActiveSceneForSynch()
34563469 {
34573470 if ( ActiveSceneSynchronization )
34583471 {
3459- if ( IsSceneObject . HasValue && ! IsSceneObject . Value )
3472+ if ( ! InScenePlaced )
34603473 {
34613474 // Just in case it is a recycled NetworkObject, unsubscribe first
34623475 SceneManager . activeSceneChanged -= CurrentlyActiveSceneChanged ;
@@ -3473,7 +3486,7 @@ private void CurrentlyActiveSceneChanged(Scene current, Scene next)
34733486 {
34743487 // Early exit if the NetworkObject is not spawned, is an in-scene placed NetworkObject,
34753488 // or the NetworkManager is shutting down.
3476- if ( ! IsSpawned || IsSceneObject != false || NetworkManagerOwner . ShutdownInProgress )
3489+ if ( ! IsSpawned || NetworkManagerOwner . ShutdownInProgress || InScenePlaced )
34773490 {
34783491 return ;
34793492 }
@@ -3483,7 +3496,7 @@ private void CurrentlyActiveSceneChanged(Scene current, Scene next)
34833496 {
34843497 // Only dynamically spawned NetworkObjects that are not already in the newly assigned active scene will migrate
34853498 // and update their scene handles
3486- if ( IsSceneObject . HasValue && ! IsSceneObject . Value && gameObject . scene != next && gameObject . transform . parent == null )
3499+ if ( gameObject . scene != next && gameObject . transform . parent == null )
34873500 {
34883501 SceneManager . MoveGameObjectToScene ( gameObject , next ) ;
34893502 SceneChangedUpdate ( next ) ;
@@ -3571,7 +3584,7 @@ internal bool UpdateForSceneChanges()
35713584 // the NetworkManager is shutting down, the NetworkObject is not spawned, it is an in-scene placed
35723585 // NetworkObject, or the GameObject's current scene handle is the same as the SceneOriginHandle
35733586 if ( ! SceneMigrationSynchronization || ! IsSpawned || NetworkManagerOwner . ShutdownInProgress ||
3574- ! NetworkManagerOwner . NetworkConfig . EnableSceneManagement || IsSceneObject != false || ! gameObject )
3587+ ! NetworkManagerOwner . NetworkConfig . EnableSceneManagement || InScenePlaced || ! gameObject )
35753588 {
35763589 // Stop checking for a scene migration
35773590 return false ;
@@ -3606,15 +3619,15 @@ internal uint CheckForGlobalObjectIdHashOverride()
36063619
36073620 // If scene management is disabled and this is an in-scene placed NetworkObject then go ahead
36083621 // and send the InScenePlacedSourcePrefab's GlobalObjectIdHash value (i.e. what to dynamically spawn)
3609- if ( ! networkManager . NetworkConfig . EnableSceneManagement && IsSceneObject . Value && InScenePlacedSourceGlobalObjectIdHash != 0 )
3622+ if ( ! networkManager . NetworkConfig . EnableSceneManagement && InScenePlaced && InScenePlacedSourceGlobalObjectIdHash != 0 )
36103623 {
36113624 return InScenePlacedSourceGlobalObjectIdHash ;
36123625 }
36133626
36143627 // If the PrefabGlobalObjectIdHash is a non-zero value and the GlobalObjectIdHash value is
36153628 // different from the PrefabGlobalObjectIdHash value, then the NetworkObject instance is
36163629 // an override for the original network prefab (i.e. PrefabGlobalObjectIdHash)
3617- if ( ! IsSceneObject . Value && GlobalObjectIdHash != PrefabGlobalObjectIdHash )
3630+ if ( ! InScenePlaced && GlobalObjectIdHash != PrefabGlobalObjectIdHash )
36183631 {
36193632 // If the PrefabGlobalObjectIdHash is already populated (i.e. InstantiateAndSpawn used), then return this
36203633 if ( PrefabGlobalObjectIdHash != 0 )
0 commit comments