Ok well dont get too excited... you still need to know kind of how to code a bit... but i just went through the Slider script and commented each line to say what it did or what i thought it did....
Then i actually added a few from a normal button as well.. This script will probably not run... but that is not what it is for.. Look at the comments and then look at the script that you want to change or modify.. look at other action scripts in the playMaker folder... everything you need is there.. Look at the EZGUI manual and Scripting Reference too... you need the base Classes from there as well as the function properties that you need to use to access the information.. like '.Value'
I probably have spelling mistakes in this as well as i could be calling something a function when it is not etc... i only know the basics my self.. Hope this helps at least a bit!! If anyone wants to make this better go right ahead.
All my comments are way to the Right..
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 { //You have to declare a unique class name.. Unique to any other scripts you have in Unity
[CheckForComponent(typeof(UISlider))] //You check for the type of Component here to make sure you have the correct one..."UISlider" is the Class Name for this one.. all the types are in the EZGUI help docs
public FsmOwnerDefault gameObject; //This is the playMaker variable for a game object and it defaults to the Owner of this FSM
public FsmEvent tapEvent; //This is an event we could set in the FSM... just added this as an example for Button types..
public FsmFloat sliderValue; //Just a Fsm Float value that you can set to a playMaker variable
private GameObject go; //This is the game object reference we use for looking for the EZGUI components... i think
private UISlider _object; //This declaration has to be the proper "Class" type that you are looking for like above from the EZGUI docs
public override void Reset() { //I am not sure what the override section is for but i put my declared variables in there.. I think that it is a condition of 'Reset' on the Action that will Reset the function with clean values
gameObject = null; //game objects and the like are set to null
tapEvent = null;
sliderValue = 0; //i set floats and ints to 0
}
public override void OnEnter() { //this portion of the script is the code that runs when it first runs.. i think... OnEnter.. get it?
// get the UISlider attached to this object
go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value; //assigns the game object reference.. i think it doesnt matter what it does as it will always be the same in these.. for me anyway
_object = go.GetComponentInChildren<UISlider>(); //This gets the EZGUI component that you specify... like before the correct 'Class' in this case again it is UISlider.
// set the delegate to capture change event
_object.AddInputDelegate(MyInputDelegate); //i put in an input delegte so you know what it looks like as well.. it will trigger 'MyInputDelegate' when there is an input to a button or something.
_object.AddValueChangedDelegate(MyDelegate); //Now this line adds a Value Changed Delegate.. instead of an Input delegate.. All that means is that if the value changes the it will call the Delegate or Function that is called MyDelegate
Finish(); //this line 'Finish()' has to do with every frame kind of functionality.. When you are using a Delegate this is fine to not run every frame as the Delegate is watching for change for you.
} //if you are not using a Delegate then you can put in a Bool and check it to either Finish or not.. I do this when i am getting values from EZGUI components with out using a Delegate..
public override string ErrorCheck() { //I am not sure what this is.. Error checking but i dont think it is really set to do anything in this case.
// TODO: Missing UISlider Object
return "";
}
void MyDelegate(IUIObject obj) { //So here is your delegate.. This is where you DO something... this one is the value changed Delegate
sliderValue.Value = _object.Value; // Just assigning the variable we have set up to the _object.Value we got from the EZGUI component.. if you are using a Fsm type variable you have to use '.Value' to get and set the value..
} //The _object.Value in this case is actually from the EZGUI manual.. '.Value' is also how you get that value.. just a coinsidence..
void MyInputDelegate(ref POINTER_INFO ptr) { //this is the basic input delegate function if called.. again just in this one as an example although i think they might even work on this type of GUI element..
if (tapEvent!=null && ptr.evt == POINTER_INFO.INPUT_EVENT.TAP){ //checking to see what kind of input it was..
Fsm.Event(tapEvent); //if it was a top then we would run send the tapEvent we set up in the FSM
}
if (pressEvent!=null && ptr.evt == POINTER_INFO.INPUT_EVENT.PRESS){
Fsm.Event(pressEvent);
}
if (releaseEvent!=null && ptr.evt == POINTER_INFO.INPUT_EVENT.RELEASE){
Fsm.Event(releaseEvent);
}
if (allEvents!=null){
Fsm.EventData.StringData = ptr.evt.ToString();
Fsm.Event(allEvents);
}
}
} //make sure all your { and } are matched... in MonoDevelop if you click beside one it will show the corresponding one.. it really helps.