From a49e9119c366456055927461e86dc3b699962345 Mon Sep 17 00:00:00 2001
From: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com>
Date: Wed, 15 Sep 2021 17:08:52 -0500
Subject: [PATCH 1/3] feat
Adding the IsSpawned bool value that is set when the InternalOnNetworkSpawn method is invoked and unset when the InternalOnNetworkDespawn method is invoked.
---
.../Runtime/Core/NetworkBehaviour.cs | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
index aa1e25338b..c497f8f0d9 100644
--- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
@@ -337,14 +337,21 @@ public virtual void OnNetworkSpawn() { }
///
public virtual void OnNetworkDespawn() { }
+ ///
+ /// Used to determine if it is safe to access NetworkObject and NetworkManager from within a NetworkBehaviour component
+ /// Primarily useful when checking NetworkObject/NetworkManager properties within FixedUpate
+ ///
+ public bool IsSpawned { get; internal set; }
+
internal void InternalOnNetworkSpawn()
{
+ IsSpawned = true;
InitializeVariables();
}
internal void InternalOnNetworkDespawn()
{
-
+ IsSpawned = false;
}
///
From c9c3fae8ac353fed592e74bd061df535bc2a965f Mon Sep 17 00:00:00 2001
From: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com>
Date: Wed, 15 Sep 2021 19:53:02 -0500
Subject: [PATCH 2/3] refactor
A better way.
---
.../Runtime/Core/NetworkBehaviour.cs | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
index c497f8f0d9..71f4cb68c5 100644
--- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
@@ -269,6 +269,12 @@ internal void __endSendClientRpc(NetworkSerializer serializer, uint rpcMethodId,
///
public bool IsOwnedByServer => NetworkObject.IsOwnedByServer;
+ ///
+ /// Used to determine if it is safe to access NetworkObject and NetworkManager from within a NetworkBehaviour component
+ /// Primarily useful when checking NetworkObject/NetworkManager properties within FixedUpate
+ ///
+ public bool IsSpawned => HasNetworkObject ? NetworkObject.IsSpawned : false;
+
///
/// Gets the NetworkObject that owns this NetworkBehaviour instance
///
@@ -337,21 +343,13 @@ public virtual void OnNetworkSpawn() { }
///
public virtual void OnNetworkDespawn() { }
- ///
- /// Used to determine if it is safe to access NetworkObject and NetworkManager from within a NetworkBehaviour component
- /// Primarily useful when checking NetworkObject/NetworkManager properties within FixedUpate
- ///
- public bool IsSpawned { get; internal set; }
-
internal void InternalOnNetworkSpawn()
{
- IsSpawned = true;
InitializeVariables();
}
internal void InternalOnNetworkDespawn()
{
- IsSpawned = false;
}
///
From 134e9dd2e17f627eb0449da3f9f125188f3a2e47 Mon Sep 17 00:00:00 2001
From: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com>
Date: Wed, 15 Sep 2021 19:57:11 -0500
Subject: [PATCH 3/3] style
Replacing LF so it is exactly as it was.
---
com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs | 1 +
1 file changed, 1 insertion(+)
diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
index 71f4cb68c5..4fee32c989 100644
--- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
+++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviour.cs
@@ -350,6 +350,7 @@ internal void InternalOnNetworkSpawn()
internal void InternalOnNetworkDespawn()
{
+
}
///