Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Nimred on January 29, 2016, 05:35:29 AM

Title: Arrays with custom class?
Post by: Nimred on January 29, 2016, 05:35:29 AM
Hi,

In a custom action I'm writing, a callback will be triggered with a custom event type provided by my internal code. For example, callback(MyEventType.ThisHappened).

Depending on this event type, I would like to trigger different FsmEvents, that would have to be defined in an array variable, as an action parameter... For example, { (MyEventType.ThisHappened, onThisHappened), (MyEventType.ThatHappened, onThatHappenedInstead) }

I tried using FsmArray, but I have only been able to make it work with simple Fsm* types; I understand it won't work with non-playmaker types because the variable types are not supported by the UI. But how about a custom class that contains only an FsmEnum and an FsmEvent, which are supported by the UI?

I would like to do something like this:

Code: [Select]
public class EventAssociation
{
    [ObjectType(typeof(MyEventType))]
    FsmEnum internalEventType;
    FsmEvent matchingFsmEvent;
}

[ArrayEditorAttribute(typeof(EventAssociation))]
public FsmArray callbackEvents;

Is there any way to make this work within the playmaker action?