Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: plinm on August 27, 2017, 07:26:41 AM
-
Hi there,
I am trying to use ArrayContains to check null reference in an array of objects (AudioClip), I leave some fields in the array unsigned and leave the Value filed in the action inspector empty, but I found it will always return not contained event.
Adding debug line in the ArrayContains action gives me this:
// output "null" in console
Debug.Log(value.GetValue());
// output "Null" in console
Debug.Log(array.Values[0]);
Note that case difference in two Null/null?
Then I try compare them to null:
// output "False" in console
Debug.Log(value.GetValue() == null);
// output "True" in console
Debug.Log(array.Values[0] == null);
Dig in further:
// output "UnityEngine.Object" in console
Debug.Log(value.GetValue().GetType());
// throws NullReferenceException
Debug.Log(array.Values[0].GetType());
SO I guess FsmVar internal did something with empty/null data and basically it is not possible to use ArrayContains to check null element.
-
Hi,
Interesting findings. Let me repro this and provide a fix or an action that checks for null explicitly.
Bye,
Jean
-
Hi,
Ok, the next update of PlayMaker will have this action taking in consideration null.
get it here meanwhile.
http://hutonggames.com/playmakerforum/index.php?topic=15696.0
Let me know how it goes :)
Bye,
Jean
-
Thanks Jean, really appreciated.