playMaker

Author Topic: Arrays of serializable classes in custom actions  (Read 1576 times)

DarkwindSean

  • Playmaker Newbie
  • *
  • Posts: 2
Arrays of serializable classes in custom actions
« on: March 09, 2018, 02:20:34 PM »
I'm working on a custom action that requires a collection of a custom serializable class type, but the functionality doesn't seem to work in the way that I'm expecting.

Here's an example of what I'm trying to do:

Code: [Select]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HutongGames.PlayMaker;

public class TestArraysAction : FsmStateAction {

    [System.Serializable]
    public class NamedObject
    {
        public GameObject go;
        public string name;
        public string id;
    }


    public NamedObject[] namedObjectsArray;

    [ArrayEditor(typeof(NamedObject))]
    public FsmArray namedObjectsFsmArray;

    public override void OnEnter()
    {
        foreach (NamedObject t in namedObjectsArray)
        {
            Debug.LogFormat("Object {0} has an ID of {1}", t.name, t.id);
        }

        foreach (NamedObject t in namedObjectsFsmArray.Values)
        {
            Debug.LogFormat("Object {0} has an ID of {1}", t.name, t.id);
        }

        Finish();
    }
}

In the action's inspector in playmaker I can change the array size (similar to how I could in a typical unity inspector), but none of the serializable class's fields show up in the inspector. I also tried using the FsmArray, but when I go to change the number of items in the collection, it immediately resets to 0.

Is there a different method for including collections of serializable classes in custom actions?

DarkwindSean

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Arrays of serializable classes in custom actions
« Reply #1 on: March 09, 2018, 04:30:48 PM »
Update: After coming back to the issue, the first solution (array of the game object) now appears to be working for me. I didn't change anything, but for some reason the elements are now showing up in the Playmaker inspector. I'll try to come up with  a repro case for it not working if I can.