playMaker

Author Topic: Exposing FSM Variables In A Custom EditorWindow [SOLVED]  (Read 1625 times)

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Exposing FSM Variables In A Custom EditorWindow [SOLVED]
« on: October 10, 2017, 06:56:53 AM »
Hi

I am creating a 'custom action' and I wanted to be able to extend the action by making a custom EditorWindow https://docs.unity3d.com/ScriptReference/EditorWindow.html and then be able to edit FSM variables within this.

I do not want to control the custom action script, I just want to make the variables editable in my EditorWindow im making. so the process is similar to how the 'playmaker controls inspector panel' works with exposing the variable using the checkbox.

Hope im making sense.

Nick

« Last Edit: November 21, 2017, 02:49:21 AM by coxy17 »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4620
    • View Profile
    • jinxtergames
Re: Exposing FSM Variables In A EditorWindow
« Reply #1 on: October 10, 2017, 07:33:28 AM »
Hi,
You can edit fsm variables.

Here you can find the playmaker api :

https://hutonggames.fogbugz.com/default.asp?W127

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Exposing FSM Variables In A Custom EditorWindow
« Reply #2 on: October 10, 2017, 07:44:40 AM »
Hi

Thanks for the link, is there a basic demo of editing a variable inside an EditorWindow at all?

Nick

Thore

  • Sr. Member
  • ****
  • Posts: 344
    • View Profile
Re: Exposing FSM Variables In A Custom EditorWindow
« Reply #3 on: October 10, 2017, 06:34:27 PM »
What you’re trying to do can be done with a simple data holder script, keeping the variables, and a custom action for getting and setting the variables into Playmaker. Though I agree, it would be more elegant if it was possible to customize how they are exposed in inspector, see here:

Peek into this, but don’t watch the whole thing yet, just know it exists :)
http://hutonggames.com/playmakerforum/index.php?topic=15917.msg74052#msg74052

Here are actual tutorials:

Cheers.


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14703
  • Official Playmaker Support
    • View Profile
Re: Exposing FSM Variables In A Custom EditorWindow
« Reply #4 on: October 10, 2017, 11:21:59 PM »
Hi,

 I can do a quick examples, but I first need to understand how you are planning on pointing to a GameObject from within your EditorWindow? is it a drop field where you drop a gameobject on it and then you access its FsmComponent, and if that's the case, do you expect a predefine set of fsm variables? or you want to show what the fsm has to offer ( that is scanning the fsm component for all its variables and showing them)

Bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Exposing FSM Variables In A Custom EditorWindow
« Reply #5 on: October 11, 2017, 12:41:19 AM »
Hi Thore,

Thanks ill take a look at those later, I have been creating custom actions for a while now and am looking to share those scripts on the forum, I wanted to go a step further with some of those custom actions using Unity's EditorWindow as i feel it will enhance the workflow.

Hi Jean,

I want to show what the FSM has to offer (scanning the FSM component).
Ideally i really wanted to find out what variables that are linked to my 'custom action' and then being able to edit those in custom EditorWindow (see screenshot as a rough very basic example). If its not possible to communicate with a custom action then scanning the FSM will be ok i guess.

Thanks

Nick


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14703
  • Official Playmaker Support
    • View Profile
Re: Exposing FSM Variables In A Custom EditorWindow
« Reply #6 on: October 12, 2017, 12:55:39 AM »
Hi,

 All of this is perfectly possible. I have attached a work in progress for introspecting everything PlayMaker inside a Project, so you'll find all usages of api to actually go trhough all fsm, states actions and it's content.

have a dedicated project for this as this is alpha, don't import this package in a real project, or back up at the very least :)


check IntrospectionXmlUtils class and you'll have methods like IntrospectFsmStateActions()  IntrospectFsmVariables() etc where you'll see how to get to everything inside an Fsm down to the value used for each actions fields.

let me know if you have questions :)


bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Exposing FSM Variables In A Custom EditorWindow
« Reply #7 on: October 13, 2017, 03:05:32 AM »
Hi Jean,

I'm not sure what you mean, I looked at the package and there's alot of new files to import, so not sure if all of them are relevant?

Are you saying that this is not possible to do this without your 'introspecting' alpha package attached?

Nick

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14703
  • Official Playmaker Support
    • View Profile
Re: Exposing FSM Variables In A Custom EditorWindow
« Reply #8 on: October 19, 2017, 11:53:48 PM »
Hi,

 These are for you to learn the api and see how things are getting accessed. You'll have to do the work inside your system, this is just to show you all the possibilities of the api as far as getting informations and pointers to various features of Fsm, states, actions, etc.

 Bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Exposing FSM Variables In A Custom EditorWindow
« Reply #9 on: October 20, 2017, 12:54:34 AM »
Hi Jean,

Ok thanks, i just got a little confused thanks for clearing this up. Im glad ive got loads examples now :)

Nick

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Exposing FSM Variables In A Custom EditorWindow [SOLVED]
« Reply #10 on: November 20, 2017, 05:13:43 AM »
Hi

I have managed to get all FSM states, events and variables just fine.

But now I need to get only the variables used by my custom action. So I can get the name of the action and compare it, but I don't know how to look at what values/variables have been associated in the FSM editor for the action?

or to make things simple i want to iterate through the fsm state action and return all of the variables and values used in each state from top to bottom.
e.g.attached.

Nick
« Last Edit: November 21, 2017, 01:27:13 AM by coxy17 »

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 352
    • View Profile
Re: Exposing FSM Variables In A Custom EditorWindow
« Reply #11 on: November 21, 2017, 02:49:09 AM »
no worries, i found the solution in the end, i was overthinking it.

for those who will read this here is how i got down into the FsmStates actions

Code: [Select]
foreach(FsmStateAction action in fsm.FsmStates[s].Actions)
{
//Debug.Log(action.GetType());
//etc....
}