@@ -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,21 @@ 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+ [ field: HideInInspector ]
1239+ [ field: SerializeField ]
1240+ public bool InScenePlaced { get ; internal set ; }
1241+
12331242 /// <summary>
12341243 /// Sets whether this NetworkObject was instantiated as part of a scene
12351244 /// </summary>
1245+ /// <remarks>Only use this when using custom scene loading</remarks>
12361246 /// <param name="isSceneObject">When true, marks this as a scene-instantiated object; when false, marks it as runtime-instantiated</param>
1247+ [ Obsolete ( "SetSceneObjectStatus is now calculated during the build." ) ]
12371248 public void SetSceneObjectStatus ( bool isSceneObject = false )
12381249 {
12391250 IsSceneObject = isSceneObject ;
@@ -1457,7 +1468,7 @@ internal Scene SceneOrigin
14571468 /// </summary>
14581469 internal NetworkSceneHandle GetSceneOriginHandle ( )
14591470 {
1460- if ( SceneOriginHandle . IsEmpty ( ) && IsSpawned && IsSceneObject != false )
1471+ if ( SceneOriginHandle . IsEmpty ( ) && IsSpawned && InScenePlaced )
14611472 {
14621473 if ( NetworkManager . LogLevel <= LogLevel . Error )
14631474 {
@@ -1622,7 +1633,7 @@ public void NetworkHide(ulong clientId)
16221633 var message = new DestroyObjectMessage
16231634 {
16241635 NetworkObjectId = NetworkObjectId ,
1625- DestroyGameObject = ! IsSceneObject . Value ,
1636+ DestroyGameObject = ! InScenePlaced ,
16261637 IsDistributedAuthority = NetworkManagerOwner . DistributedAuthorityMode ,
16271638 IsTargetedDestroy = NetworkManagerOwner . DistributedAuthorityMode ,
16281639 TargetClientId = clientId , // Just always populate this value whether we write it or not
@@ -1750,7 +1761,7 @@ private void OnDestroy()
17501761 var isStillValid = gameObject != null && gameObject . scene . IsValid ( ) && gameObject . scene . isLoaded ;
17511762
17521763 // 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 )
1764+ if ( ! isAuthorityDestroy && ! InScenePlaced && isStillValid )
17541765 {
17551766 if ( networkManager . LogLevel <= LogLevel . Error )
17561767 {
@@ -1849,7 +1860,7 @@ internal void SpawnInternal(bool destroyWithScene, ulong ownerClientId, bool pla
18491860 }
18501861 }
18511862
1852- if ( ! NetworkManagerOwner . SpawnManager . AuthorityLocalSpawn ( this , NetworkManagerOwner . SpawnManager . GetNetworkObjectId ( ) , IsSceneObject . HasValue && IsSceneObject . Value , playerObject , ownerClientId , destroyWithScene ) )
1863+ if ( ! NetworkManagerOwner . SpawnManager . AuthorityLocalSpawn ( this , NetworkManagerOwner . SpawnManager . GetNetworkObjectId ( ) , InScenePlaced , playerObject , ownerClientId , destroyWithScene ) )
18531864 {
18541865 if ( NetworkManagerOwner . LogLevel <= LogLevel . Normal )
18551866 {
@@ -2528,8 +2539,7 @@ internal bool ApplyNetworkParenting(bool removeParent = false, bool ignoreNotSpa
25282539 // Handle the first in-scene placed NetworkObject parenting scenarios. Once the m_LatestParent
25292540 // has been set, this will not be entered into again (i.e. the later code will be invoked and
25302541 // 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 )
2542+ if ( transform . parent != null && ! removeParent && ! m_LatestParent . HasValue && InScenePlaced )
25332543 {
25342544 var parentNetworkObject = transform . parent . GetComponent < NetworkObject > ( ) ;
25352545
@@ -3271,7 +3281,7 @@ internal SerializedObject Serialize(ulong targetClientId = NetworkManager.Server
32713281 NetworkObjectId = NetworkObjectId ,
32723282 OwnerClientId = OwnerClientId ,
32733283 IsPlayerObject = IsPlayerObject ,
3274- IsSceneObject = IsSceneObject ?? true ,
3284+ IsSceneObject = InScenePlaced ,
32753285 DestroyWithScene = DestroyWithScene ,
32763286 DontDestroyWithOwner = DontDestroyWithOwner ,
32773287 HasOwnershipFlags = NetworkManagerOwner . DistributedAuthorityMode ,
@@ -3456,7 +3466,7 @@ internal void SubscribeToActiveSceneForSynch()
34563466 {
34573467 if ( ActiveSceneSynchronization )
34583468 {
3459- if ( IsSceneObject . HasValue && ! IsSceneObject . Value )
3469+ if ( ! InScenePlaced )
34603470 {
34613471 // Just in case it is a recycled NetworkObject, unsubscribe first
34623472 SceneManager . activeSceneChanged -= CurrentlyActiveSceneChanged ;
@@ -3473,7 +3483,7 @@ private void CurrentlyActiveSceneChanged(Scene current, Scene next)
34733483 {
34743484 // Early exit if the NetworkObject is not spawned, is an in-scene placed NetworkObject,
34753485 // or the NetworkManager is shutting down.
3476- if ( ! IsSpawned || IsSceneObject != false || NetworkManagerOwner . ShutdownInProgress )
3486+ if ( ! IsSpawned || NetworkManagerOwner . ShutdownInProgress || InScenePlaced )
34773487 {
34783488 return ;
34793489 }
@@ -3483,7 +3493,7 @@ private void CurrentlyActiveSceneChanged(Scene current, Scene next)
34833493 {
34843494 // Only dynamically spawned NetworkObjects that are not already in the newly assigned active scene will migrate
34853495 // and update their scene handles
3486- if ( IsSceneObject . HasValue && ! IsSceneObject . Value && gameObject . scene != next && gameObject . transform . parent == null )
3496+ if ( gameObject . scene != next && gameObject . transform . parent == null )
34873497 {
34883498 SceneManager . MoveGameObjectToScene ( gameObject , next ) ;
34893499 SceneChangedUpdate ( next ) ;
@@ -3571,7 +3581,7 @@ internal bool UpdateForSceneChanges()
35713581 // the NetworkManager is shutting down, the NetworkObject is not spawned, it is an in-scene placed
35723582 // NetworkObject, or the GameObject's current scene handle is the same as the SceneOriginHandle
35733583 if ( ! SceneMigrationSynchronization || ! IsSpawned || NetworkManagerOwner . ShutdownInProgress ||
3574- ! NetworkManagerOwner . NetworkConfig . EnableSceneManagement || IsSceneObject != false || ! gameObject )
3584+ ! NetworkManagerOwner . NetworkConfig . EnableSceneManagement || InScenePlaced || ! gameObject )
35753585 {
35763586 // Stop checking for a scene migration
35773587 return false ;
@@ -3606,15 +3616,15 @@ internal uint CheckForGlobalObjectIdHashOverride()
36063616
36073617 // If scene management is disabled and this is an in-scene placed NetworkObject then go ahead
36083618 // and send the InScenePlacedSourcePrefab's GlobalObjectIdHash value (i.e. what to dynamically spawn)
3609- if ( ! networkManager . NetworkConfig . EnableSceneManagement && IsSceneObject . Value && InScenePlacedSourceGlobalObjectIdHash != 0 )
3619+ if ( ! networkManager . NetworkConfig . EnableSceneManagement && InScenePlaced && InScenePlacedSourceGlobalObjectIdHash != 0 )
36103620 {
36113621 return InScenePlacedSourceGlobalObjectIdHash ;
36123622 }
36133623
36143624 // If the PrefabGlobalObjectIdHash is a non-zero value and the GlobalObjectIdHash value is
36153625 // different from the PrefabGlobalObjectIdHash value, then the NetworkObject instance is
36163626 // an override for the original network prefab (i.e. PrefabGlobalObjectIdHash)
3617- if ( ! IsSceneObject . Value && GlobalObjectIdHash != PrefabGlobalObjectIdHash )
3627+ if ( ! InScenePlaced && GlobalObjectIdHash != PrefabGlobalObjectIdHash )
36183628 {
36193629 // If the PrefabGlobalObjectIdHash is already populated (i.e. InstantiateAndSpawn used), then return this
36203630 if ( PrefabGlobalObjectIdHash != 0 )
0 commit comments