playMaker

Author Topic: Problem with embedded arrays  (Read 1549 times)

olpenelle

  • Playmaker Newbie
  • *
  • Posts: 4
Problem with embedded arrays
« on: March 04, 2014, 06:13:59 PM »
There seem to be a bug in PlayMaker 1.7.7:

If you have a serializable class that contains an Array:
Code: [Select]
[Serializable]
public class TestA
{
    public int[] testArray = new int[0];
}

and use that inside a PlayMaker action:
Code: [Select]
public class MyAction : FsmAction
{
    public TestA myTestParameters = new TestA();
}

The PlayMaker editor will get confused when trying to serialize that (it'll start happening only after you change the size of the array in the editor:

Code: [Select]
ArgumentException: Object type int[] cannot be converted to target type: TestA
Parameter name: val
System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoField.cs:133)
System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/FieldInfo.cs:150)
HutongGames.PlayMakerEditor.ActionEditor.UpdateArrays ()
HutongGames.PlayMakerEditor.ActionEditor.Update ()
HutongGames.PlayMakerEditor.StateInspector.Update ()
HutongGames.PlayMakerEditor.InspectorPanel.Update ()
HutongGames.PlayMakerEditor.FsmEditor.Update ()
FsmEditorWindow.Update () (at Assets/PlayMaker/Editor/FsmEditorWindow.cs:611)

Is there a known workaround or a fix underway?

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Problem with embedded arrays
« Reply #1 on: March 12, 2014, 04:33:47 AM »
Hi,

 yes, I think it is a known issue. I can't get this to work neither.

bye,

 Jean

deepcanvas

  • Playmaker Newbie
  • *
  • Posts: 7
Re: Problem with embedded arrays
« Reply #2 on: March 14, 2014, 08:41:28 PM »
Same here... any word on a fix?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Problem with embedded arrays
« Reply #3 on: March 18, 2014, 09:11:48 AM »
Hi,

 I doubt there is s fix actually, it's a unity restriction with how it serializes data.

 the way to get around this is to use scriptable objects, study this, this is likely your way out.

bye,

 Jean