Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: plinm on August 27, 2017, 07:26:41 AM

Title: Using ArrayContains action to check null element[SOLVED]
Post 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:

Code: [Select]
// 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:

Code: [Select]
// output "False" in console
Debug.Log(value.GetValue() == null);
// output "True" in console
Debug.Log(array.Values[0] == null);

Dig in further:

Code: [Select]
// 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.

Title: Re: Using ArrayContains action to check null element
Post by: jeanfabre on August 28, 2017, 04:53:09 AM
Hi,

 Interesting findings. Let me repro this and provide a fix or an action that checks for null explicitly.

 Bye,

 Jean
Title: Re: Using ArrayContains action to check null element
Post by: jeanfabre on August 28, 2017, 06:12:56 AM
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
Title: Re: Using ArrayContains action to check null element
Post by: plinm on August 28, 2017, 09:20:20 AM
Thanks Jean, really appreciated.