playMaker

Author Topic: How to create states and transitions programatically?  (Read 2107 times)

davenirline

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
How to create states and transitions programatically?
« on: May 14, 2012, 03:00:52 AM »
I want to provide our designer with an XML file such that when it's loaded to the game, it creates the states and transitions specified in it.

So how do you create states and transitions programatically?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14126
  • Official Playmaker Support
    • View Profile
Re: How to create states and transitions programatically?
« Reply #1 on: May 14, 2012, 03:19:42 AM »
Hi,

 Interesting questions. I am not sure how this can be done, tho I can recall I post where they mentioned tha had that working.

 I would welcome the ability to save and load Fsm as xml, that would be really great ( including the position of the states m links types, colors etc etc). That would open a lot of possibilities, not just during runtime but also for documentation, external viewers etc etc.


 Bye,

 Jean

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3608
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: How to create states and transitions programatically?
« Reply #2 on: May 14, 2012, 10:13:38 PM »
The Playmaker editor classes used to build FSMs use UnityEditor classes, so they can't be used at runtime. This keeps the runtime classes as lightweight as possible.

Of course you can reproduce anything the editor does in your own code, but you'd really need to poke around the API to figure it out. Adding states and transitions wouldn't be too difficult, but adding actions is a lot more involved! To be honest, supporting this is not terribly high priority right now... by far the vast majority of users will use the FSM Editor to make FSMs.

I'm curious what the use case is for defining the FSM in XML, and not in the editor... If you describe the problem you're trying to solve, there may be another solution...

davenirline

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: How to create states and transitions programatically?
« Reply #3 on: May 15, 2012, 01:17:24 AM »
Our problem is collaboration. We can't really afford another Unity Pro license (which has the text file serialization) for our designer to be able to tweak behaviors and test the game. She is only using the free version. So I was thinking if the designer could edit an XML file instead and generate the state in editor time (not runtime). She could then commit just the XML file instead of Unity files.

davenirline

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: How to create states and transitions programatically?
« Reply #4 on: May 15, 2012, 02:03:24 AM »
Or, rather, could you please guide me where in the editor scripts does the state creation begin. The name of the class and function call is enough for me and I can work from there.

davenirline

  • Playmaker Newbie
  • *
  • Posts: 9
    • View Profile
Re: How to create states and transitions programatically?
« Reply #5 on: May 15, 2012, 02:14:53 AM »
The closest I could find is FsmEditorWindow. The other windows are "thin wrappers" (as explained in comments). I can't find the exact function call for creating states and transitions. Perhaps these are hidden in DLLs?