PlayMaker Updates & Downloads > Share New Actions

EzGUI button input delegate for tap and/or all events

(1/2) > >>

jeanfabre:
Hi,

 Following the great action from sP0CkEr ( http://hutonggames.com/playmakerforum/index.php?topic=98.0 ), here's a variant that let you catch the tap event directly, so no post processing required in fsm and you can also if you want catch all events via another event.


--- Code: ---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>
///
/// <remarks>
/// Modified the original EzButtonInvoke, to catch only the tap event and/or all events. It's likely anyway that
///  only the tap event is needed on the fsm side, since ezgui will largely deal with the look and feel of the button itself.
/// </remarks>
///
[ActionCategory("EzGui")]
[Tooltip("EzGui Button Click")]

public class EzButtonInputDelegate : FsmStateAction {

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

private GameObject go;
private UIButton _object;

public override void Reset() {
gameObject = null;
tapEvent = null;
allEvents = 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.AddInputDelegate(MyInputDelegate);
Finish();
}

public override string ErrorCheck() {

// TODO: Missing UIButton Object

return "";
}


void MyInputDelegate(ref POINTER_INFO ptr) {

if (tapEvent!=null && ptr.evt == POINTER_INFO.INPUT_EVENT.TAP){
Fsm.Event(tapEvent);
}

if (allEvents!=null){
Fsm.EventData.StringData = ptr.evt.ToString();
Fsm.Event(allEvents);
}

}// MyInputDelegate

}

--- End code ---


Bye,

 Jean

tobbeo:
Thanks!

I need to get to do those SpriteManager actions... I have a few weeks off work so now might be a good time. Unless someone more knowledgeable than me does them first! It should be fairly simple though so I'll try...

sP0CkEr:
Let's collaborate, what actions do u think would be useful at first?

Movement?
Collision?

- spocker

jeanfabre:
Hi,

-- SM2 We'd need I think actions to control sprite animations, I find myself using a lot of that, instead of animating at a constant framerate for example, useful for powerbars, progress bars, realistic turny buttons etc etc.

-- SM2 Pause, play, etc etc

-- EzGui, controllers for the scroll list maybe

The thing that I don't know is how we can tight playmaker and ezgui sm2 when they initialize, I have already some trouble with SM2 and Ezgui in that phase. I'd need more time to properly experiment.

Bye,

 Jean

qholmes:


Umm how do i use this?

I am totally new to EZ GUI and playMaker. I have an EZ GUI button set up and it is working.. So i added a playMaker script to it and then put the EZ Button Input Delegate on the Start event.. Not sure if this is correct.. or where to go from here?

Q

Navigation

[0] Message Index

[#] Next page

Go to full version