playMaker

Author Topic: set Target FSM via script (UIEventsToPlaymakerFSM)[SOLVED]  (Read 3191 times)

amaranth

  • Full Member
  • ***
  • Posts: 172
set Target FSM via script (UIEventsToPlaymakerFSM)[SOLVED]
« on: September 28, 2012, 02:11:24 PM »
I've run into a situation where I need to set the Target FSM field in the UIEventsToPlaymakerFSM, using a NGUI script called UIPopupList.

I'm not sure how to get pmEvents.targetFSM to get the game object that has the FSM. I tried using this code to reference the game object, but I get a conversion error, since targetFSM is looking for an FSM component:
var otherGameObject = GameObject.Find("Other");

Anyone know a solution? I'm trying to reference a game object in the Hierarchy called Monitor that contains an FSM called Click.

Code: [Select]
UIEventsToPlaymakerFSM pmEvents = UIEventsToPlaymakerFSM.Get(lbl.gameObject); //works
pmEvents.onClickEvent = "Item Clicked";  //works
pmEvents.targetFSM = //What goes here?
« Last Edit: October 02, 2012, 05:45:20 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: set Target FSM via script (UIEventsToPlaymakerFSM)
« Reply #1 on: October 01, 2012, 01:29:33 AM »
Hi,

 never played with that, but the target Fsm is likely a reference to the PlayMaker Component itself-

 Fsm are components attached to a gameObject like any other components in Unity.

bye,

 Jean

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: set Target FSM via script (UIEventsToPlaymakerFSM)
« Reply #2 on: October 01, 2012, 03:57:06 PM »
Woot, it worked!!!

Added this to NGUI's UIPopupList.cs:
Code: [Select]
// playmaker event listener
var go = GameObject.Find("Click Monitor");
PlayMakerFSM fsmComponent;
fsmComponent = go.GetComponent<PlayMakerFSM>();

UIEventsToPlaymakerFSM pmEvents = UIEventsToPlaymakerFSM.Get(lbl.gameObject);
pmEvents.onClickEvent = "Item Clicked";
pmEvents.targetFSM = fsmComponent;