This is the one that i wrote for getting slider values... works for me.. i have a few EZ GUI Actions that are all based on what Jean wrote and submitted in the Actions Share section.. I have managed to get pretty much anything from EZ GUI now..
Thanks again Jean!
Let me know if this works for you. I just did this up when i saw your post. I was going to need one in the future but had not gotten to it yet. I think i got it all correct... just did a quick test and it seemed to work ok.
Q
using UnityEngine;
using HutongGames.PlayMaker;
/// <summary>
/// PlayMaker Action for Delegating when a UISlider
/// 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 Slider
/// to capture events that have been triggered by the
/// button.
/// </para>
/// <remarks>The Owner must contain a UISlider class</remarks>
/// <remarks>See the EZGui Documentation for More information on this Delegate</remarks>
///
///
[ActionCategory("EzGui")]
[Tooltip("EzGui Slider Get Value")]
public class UISliderValueDelegate : FsmStateAction {
[CheckForComponent(typeof(UISlider))]
public FsmOwnerDefault gameObject;
public FsmFloat sliderValue;
private GameObject go;
private UISlider _object;
public override void Reset() {
gameObject = null;
sliderValue = 0;
}
public override void OnEnter() {
// get the UISlider attached to this object
go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;
_object = go.GetComponentInChildren<UISlider>();
// set the delegate to capture change event
_object.AddValueChangedDelegate(MyDelegate);
Finish();
}
public override string ErrorCheck() {
// TODO: Missing UISlider Object
return "";
}
void MyDelegate(IUIObject obj) {
sliderValue.Value = _object.Value;
}
}