playMaker

Author Topic: Opening the FSM Editor from outside PlayMaker  (Read 1774 times)

martinellison

  • Playmaker Newbie
  • *
  • Posts: 1
Opening the FSM Editor from outside PlayMaker
« on: July 19, 2017, 02:17:57 AM »
We would like to automate opening the PlayMaker FSM Editor on a specific Template.

Using `AssetDatabase.OpenAsset` on the template opens it in the inspector, and we can then click on the Edit button to open the template in PlayMaker. What we would like to do is to cut out the Edit button and just bring up the PlayMaker Editor on the template directly in code. Is there any way to do this?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Opening the FSM Editor from outside PlayMaker
« Reply #1 on: July 19, 2017, 05:35:46 AM »
Hi,

To open and/or select the Editor window you can use these :

Code: [Select]
using HutongGames.PlayMakerEditor;

FsmEditorWindow.OpenWindow();

Then select your template in your project, for example like this:

Code: [Select]
Selection.activeObject = AssetDatabase.LoadAssetAtPath("Assets/PlayMaker Custom Templates/Logic/GetLoadedLevel.asset", typeof(FsmTemplate));
This should highlight the template in the Playmaker Editor window :)

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Opening the FSM Editor from outside PlayMaker
« Reply #2 on: July 19, 2017, 10:10:11 AM »
There are also a couple of overloads for FsmEditorWindow.OpenWindow:

Code: [Select]
        public static void OpenWindow(FsmTemplate fsmTemplate)
        public static void OpenWindow(PlayMakerFSM fsmComponent)

So you could do this:

Code: [Select]
using HutongGames.PlayMakerEditor;

FsmEditorWindow.OpenWindow(myTemplate);

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Opening the FSM Editor from outside PlayMaker
« Reply #3 on: July 20, 2017, 05:24:12 AM »
Hi,
That is indeed much easier :)