Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Guillaume Portes on October 09, 2012, 11:53:51 AM

Title: [SOLVED] Adding action member types
Post by: Guillaume Portes on October 09, 2012, 11:53:51 AM
Hello,

I'm new to PlayMaker so apologies if this is either stupid or has been answered some other obvious place, but I haven't come across the solution.
I'm writing a custom action which would ideally expose a variable of a custom type, as follows:

[Serializable]
public class MyCustomParameter
{
    string a;
    string b;
    string c;
    int i;
    float f;
}

namespace HutongGames.PlayMaker.Actions
{
    public class MyAction : FsmStateAction
    {
         public MyCustomParameter[] MCP;
         ...
    }
}

That doesn't work - i.e. MCP doesn't come up in the action inspector -, throwing "Unsupported Type: MyCustomParameter" in the actions browser, and "ActionData: Missing LoadActionField for type: MyCustomParameter".

I really want to do things this way as I want to be able to fill MCP with variables that are retrieved by other states of the FSM.

Am I missing something, or is it only possible to use a certain set of types as Action members?

Thanks!

Guillaume.
Title: Re: Adding action member types
Post by: jeanfabre on October 10, 2012, 01:51:47 AM
Bonjour Guillaume :)

Unfortunatly, Playmaker Actions do have limitations in that area.

 I would hide away the MyCustomParameter by exposing each properties normally, using one variable per property, and then within the OnEnter, you get all the details from the action interface and create your MyCustomParameter and inject in each properties what the user choose

If you need a working example let me know.

bye,

 Jean
Title: Re: Adding action member types
Post by: Guillaume Portes on October 10, 2012, 04:19:36 AM
Merci Jean :)

Do you know if there is an actual stumbling block, or is it "just" something that could be implemented later on?
I ended up doing roughly what you suggested, which of course works, but is not too convenient when wanting to deal with arrays.

For instance, instead of having an action that can call MyArrayFunction(MyCustomParameter[] p) I have to call MyFunction(MyCustomParameter) "n" times.

Thanks!

G.
Title: Re: Adding action member types
Post by: jeanfabre on October 11, 2012, 03:41:42 AM
Hi,

I do not know when and if action UI will become more flexible, so I would stick with alternatives for now. I don^t think it's difficult to open, but I Think it would lead to a less solid system because we would start doing crazy things... I think it's more about keeping consistency then anything else, which is a very good point actually, only constraining for advanced use.

 Have you checked ArrayMaker? this might help you achieve more of what you want.

https://hutonggames.fogbugz.com/default.asp?W715 (https://hutonggames.fogbugz.com/default.asp?W715)

bye,

 Jean
Title: Re: Adding action member types
Post by: Guillaume Portes on October 11, 2012, 04:03:48 AM
I did take a look at arrayMaker indeed, but only to see if it was adding its own "action member types", which it doesn't (as you know ;) ).
I'll look at it again to see if it can give me a better solution than the one I have at the moment.

Thanks again for the answers Jean, very helpful!

G.