playMaker

Author Topic: Using ArrayContains action to check null element[SOLVED]  (Read 1841 times)

plinm

  • Playmaker Newbie
  • *
  • Posts: 25
Using ArrayContains action to check null element[SOLVED]
« 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.

« Last Edit: August 29, 2017, 03:01:02 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using ArrayContains action to check null element
« Reply #1 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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Using ArrayContains action to check null element
« Reply #2 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

plinm

  • Playmaker Newbie
  • *
  • Posts: 25
Re: Using ArrayContains action to check null element
« Reply #3 on: August 28, 2017, 09:20:20 AM »
Thanks Jean, really appreciated.