From 28b1e8b374d5cb68e79fba9019df3bcff230107f Mon Sep 17 00:00:00 2001 From: MrGadget1024 <9826063+MrGadget1024@users.noreply.github.com> Date: Tue, 9 Jan 2024 19:43:17 -0500 Subject: [PATCH] fix(NetworkBehaviour): Improved OnValidate Error Logging References the offending object so it gets highlighted in the Editor when the error is clicked. --- Assets/Mirror/Core/NetworkBehaviour.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Mirror/Core/NetworkBehaviour.cs b/Assets/Mirror/Core/NetworkBehaviour.cs index 0e1ca5b25..45a3e0809 100644 --- a/Assets/Mirror/Core/NetworkBehaviour.cs +++ b/Assets/Mirror/Core/NetworkBehaviour.cs @@ -316,14 +316,14 @@ protected virtual void OnValidate() if (GetComponent() == null && GetComponentInParent(true) == null) { - Debug.LogError($"{GetType()} on {name} requires a NetworkIdentity. Please add a NetworkIdentity component to {name} or it's parents."); + Debug.LogError($"{GetType()} on {name} requires a NetworkIdentity. Please add a NetworkIdentity component to {name} or it's parents.", this); } #elif UNITY_2020_3_OR_NEWER // 2020 only has GetComponentsInParents(active), we can use this too NetworkIdentity[] parentsIds = GetComponentsInParent(true); int parentIdsCount = parentsIds != null ? parentsIds.Length : 0; if (GetComponent() == null && parentIdsCount == 0) { - Debug.LogError($"{GetType()} on {name} requires a NetworkIdentity. Please add a NetworkIdentity component to {name} or it's parents."); + Debug.LogError($"{GetType()} on {name} requires a NetworkIdentity. Please add a NetworkIdentity component to {name} or it's parents.", this); } #endif #endif