From 6b12ed2a8d17caa53057b77648d87ecf5e8c5439 Mon Sep 17 00:00:00 2001 From: Michal Nehrajsa Date: Wed, 11 Feb 2026 09:46:25 +0100 Subject: [PATCH] [Fix] ArgumentNullException: Value cannot be null. Parameter name: unityObject sometimes, "this" is null due to corrupt/invalid serialized data or the object got destroyed earlier. --- Runtime/Scripts/Variables/DashVariablesController.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Runtime/Scripts/Variables/DashVariablesController.cs b/Runtime/Scripts/Variables/DashVariablesController.cs index b00ecfa7..360253c7 100644 --- a/Runtime/Scripts/Variables/DashVariablesController.cs +++ b/Runtime/Scripts/Variables/DashVariablesController.cs @@ -87,6 +87,11 @@ public void SetVariable(string p_name, T p_value) void ISerializationCallbackReceiver.OnAfterDeserialize() { + if (this.SafeIsUnityNull()) + { + return; + } + // Debug.Log("OnAfterDeserialize: "+_serializedVariables); using (var cachedContext = Cache.Claim()) { @@ -115,6 +120,10 @@ void ISerializationCallbackReceiver.OnAfterDeserialize() void ISerializationCallbackReceiver.OnBeforeSerialize() { // Debug.Log("OnBeforeSerialize"); + if (this.SafeIsUnityNull()) + { + return; + } using (var cachedContext = Cache.Claim()) { @@ -146,4 +155,4 @@ public void MarkDirty() #endif } } -} \ No newline at end of file +}