1
PlayMaker Help / Re: Activate Game Object
« on: July 28, 2011, 04:29:22 PM »
Thanks for the help! It worked.

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
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);
}
}