playMaker

Author Topic: FSMVariable needs to be 'new'ed[SOLVED]  (Read 797 times)

allender

  • Playmaker Newbie
  • *
  • Posts: 17
FSMVariable needs to be 'new'ed[SOLVED]
« on: July 02, 2019, 10:15:41 AM »
Playmaker 1.9.1p15 unity 18.3.6f

I have created a new action and have had to write a custom editor for the action due to wanting to put in a custom dropdown that is searchable.  I have used EditField() for a couple of the fields in the action, but have written custom code for one of the fields, which is an FSMInt.  I have declared

Code: [Select]
FSMInt  id;
then the custom editor code actually does a bunch of stuff to convert item in a list to the proper id, etc.  But the one thing that I've found is that id is null when the object is first created.  I had to do

Code: [Select]
public override void Reset()
{
   id = new FsmInt(0);
}

in order to not have uinhandled exceptions in the action Reset code so that id is not null in the custom editor.  Why is this?  It just seems strange that I don't have to do this for other variables that are edited with EditField so I suspect something is happening behind the scenes.

I'm fine with this solution, but just want to make sure that I'm not missing something subtle or buggy.
« Last Edit: July 04, 2019, 05:11:34 AM by jeanfabre »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: FSMVariable needs to be 'new'ed
« Reply #1 on: July 03, 2019, 08:11:12 PM »
Hi.
if you want a value to be set, then you could do  id = 0; instead of new

what are you doing in the action?

it should not give an error .

is the value user input or are you receiving the value?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: FSMVariable needs to be 'new'ed
« Reply #2 on: July 04, 2019, 05:11:24 AM »
Hi,

 yes, this is by design, it's ok to do that when you use custom editor and complex setup.

the same would be true if you had a custom serialized class.
Bye,

 Jean