playMaker

Author Topic: EZ GUI Button Action  (Read 6084 times)

henk

  • Playmaker Newbie
  • *
  • Posts: 24
    • Dawson 3D
EZ GUI Button Action
« on: July 15, 2011, 06:18:27 PM »
It's starting to work! Thanks for the help. Here's a video that shows where I'm at. I have to admit, after a lot of tries, I'm not sure how to set up an EZ Gui button to work with Playmaker. It's kind of working -  Here's what I've got...

http://gallery.me.com/henkdawson#100747

Note: On my button, I think that I should have the "scale up" state go back to the "wait for input" state but I don't know how to do this. any ideas?

Code: [Select]
using UnityEngine;
using HutongGames.PlayMaker;

/// <summary>
/// PlayMaker Action for Delegating when a UIButton
/// has been invoked.
/// </summary>
/// <para>
/// This Action should be placed in the Start action of your
/// FSM. It will add itself as a delegate to the EZGui Button
/// to capture events that have been triggered by the
/// button.
/// </para>
/// <remarks>The Owner must contain a UIButton class</remarks>
/// <remarks>See the EZGui Documentation for More information on this Delegate</remarks>

[ActionCategory("EzGui")]
[Tooltip("EzGui Button Click")]

public class EzButtonInvoke : FsmStateAction {

[CheckForComponent(typeof(UIButton))]
public FsmOwnerDefault gameObject;
public FsmEvent invokeEvent;

private GameObject go;
private UIButton _object;

public override void Reset() {
gameObject = null;
invokeEvent = null;
}

public override void OnEnter() {

// get the UIButton attached to this object

go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;
_object = go.GetComponentInChildren<UIButton>();

// set the delegate to capture change event

_object.AddValueChangedDelegate(MyDelegate);

Finish();
}

public override string ErrorCheck() {

// TODO: Missing UIButton Object

return "";
}

void MyDelegate ( IUIObject obj ) {
Fsm.Event(invokeEvent);

}
}

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: EZ GUI Button Action
« Reply #1 on: July 16, 2011, 11:13:56 AM »
Hi Henk,

 On your Scale up state, add a transition and select "Finished", link that transition back to the "Scale" state. Same with scale down. then when the mouse is Down, you go to the "scale up" state, do your thing and back, ready for another mouse event.

 Or do I misunderstand your question?

 Bye,

 Jean