Probably not being very clear here.. thanks for the patience.
So we have a generic data class called ActionOnHelper... looks like this...
using UnityEngine;
using System.Collections;
/** generic data class used to provide public variables and functions for performing actions after an operation
* ShowHide, Mover, etc. Have an action helper that runs at the end of the action..
*/
[System.Serializable]
public class ActionOnHelper
{
public AudioClip playSound;
public GameObject audioSource;
public StatePrecondition AddState;
public StatePrecondition RemoveState;
public string methodName; // call out
public MonoBehaviour reflectTo;
public ShowHide[] ShowObjects;
public ShowHide[] HideObjects;
public Mover[] MoveObjects;
public Rotator[] RotateObjects;
public int GoToLevel = -1;
public string GoToChapter;
public ShowString Show_String;
public ListOfMultiStateToggles Toggle;
public int TogleIndex;
public ShowParticle[] showParticles;
public ZoomState ZoomControl = ZoomState.NONE;
public int PlayAnimation = -1;
public PackedSprite[] AdditionalSprites;
public int PlayAnimatedSequence = -1;
public HotSpotIsDone[] TheHotSpot;
public void RunAction(GameObject go, DialogBox textBox)
{
//Do stuff here
}
that class is used as a system wide variable whenever we need to run actions based on input/events. In the instance of the hotspot we use it like this..
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class HotSpot : MonoBehaviour, IUIObject
{
/// <summary>
/// Controls whether this control is in an enabled
/// state or not. If it is not, input is not processed.
/// This can also be used to cause a control to take on
/// a "grayed out" appearance when disabled.
/// </summary>
public bool m_bEnabled = true;
public Scene_Items_t scene_item = Scene_Items_t.NONE;
public StringAction_t clickStringAction = StringAction_t.look;
public POINTER_INFO.INPUT_EVENT Type = POINTER_INFO.INPUT_EVENT.TAP;
public ConditionHelper EnabledWhen;
public ActionOnHelper ActionsOnClick = null;
// the inventory item that this hot spot wants to perform an action
public DialogBox TextBox;
Vector3 colliderSize;
protected List<EZInputDelegate> inputDelegates = null;
void Start ()
{
BoxCollider cs = GetComponent<BoxCollider> ();
if (cs != null)
{
colliderSize = GetComponent<BoxCollider> ().size;
}
}
public virtual bool controlIsEnabled {
get { return (m_bEnabled); }
set { EnableDisable (value); }
}
public virtual bool DetargetOnDisable
{
get;
set;
}
protected virtual void EnableDisable (bool bEnable)
{
if (m_bEnabled) {
if (bEnable == false) {
// disable an enabled object
Vector3 v = new Vector3 (0.0f, 0.0f, 0.0f);
GetComponent<BoxCollider> ().size = v;
}
m_bEnabled = false;
} else {
// disabled
if (bEnable == true) {
GetComponent<BoxCollider> ().size = colliderSize;
m_bEnabled = true;
}
}
}
// called when the inventory item is hoving over this hot spot
public virtual bool HitTestWantsInventory(Inventory_Items_t item)
{
return (false);
}
// returns the number of inventory items to remove
public virtual int OnDropInventoryItem(Inventory_Items_t item)
{
return (0); // don't accept the inventory
}
// Accessor for getting/setting a reference to the
// object that contains this one.
public virtual IUIContainer Container {
get { return (null); }
set { }
}
// Requests that the IUIObject accept the specified
// container as its container. It should search
// up the hierarchy of parent objects first to see
// if a more immediate parent is a container, and
// if so, reject the request.
// <param name="cont">A reference to the object that is requesting containership.</param>
// <returns>True if succeeded, false if a closer container was found.</returns>
public virtual bool RequestContainership (IUIContainer cont)
{
return (false);
}
// Is called when a control receives the keyboard focus.
// <returns>The object should return true if it can process
// keyboard input (will result on displaying an on-screen
// keyboard on iPhone OS devices), or false if it cannot.</returns>
public virtual bool GotFocus ()
{
return (false);
}
/// <summary>
/// This is where input handling code should go in any derived class.
/// </summary>
/// <param name="ptr">POINTER_INFO struct that contains information on the pointer that caused the event, as well as the event that occurred.</param>
public virtual void OnInput (POINTER_INFO ptr)
{
if (inputDelegates != null)
{
foreach (EZInputDelegate d in inputDelegates)
d (ref ptr);
}
if (ptr.evt == POINTER_INFO.INPUT_EVENT.NO_CHANGE)
return;
if (ptr.evt == Type || (Type == POINTER_INFO.INPUT_EVENT.DRAG && ptr.evt == POINTER_INFO.INPUT_EVENT.TAP))
{
if (ptr.hitInfo.collider == null) {
// Debug.Log ("EZSimpleHotSpot::Delegate - no raycast info?");
}
else if (ptr.hitInfo.collider.gameObject == gameObject)
{
if (ClickActionSubclass(ref ptr) == true)
{
Precondition prec = null;
if (EnabledWhen.CheckConditions (ref prec) == true)
{
if (scene_item != Scene_Items_t.NONE)
{
ChapterData.instance.ShowString (TextBox, scene_item, this.clickStringAction, Inventory_Items_t.NONE);
}
if (ClickActionSubclass2(ref ptr) == true && ActionsOnClick != null)
{
ActionsOnClick.RunAction(this.gameObject, TextBox);
}
}
else if (prec != null)
{
EnabledWhen.ShowString(TextBox, prec, this.scene_item, Inventory_Items_t.NONE);
}
else
{
}
}
}
}
}
// subclasses can implement this in response to an event
protected virtual bool ClickActionSubclass(ref POINTER_INFO ptr) { return (true); }
// this is called AFTER all conditions are evaluated.1 to 1 with "ActionOnClick"
protected virtual bool ClickActionSubclass2(ref POINTER_INFO ptr) { return (true); }
public virtual void SetInputDelegate(EZInputDelegate del)
{
inputDelegates = new List<EZInputDelegate>();
inputDelegates.Add(del);
}
/// <summary>
/// Adds a method to be called when input occurs (input is forwarded from OnInput()).
/// </summary>
/// <param name="del">A method that conforms to the EZInputDelegate pattern.</param>
public virtual void AddInputDelegate(EZInputDelegate del)
{
if (inputDelegates == null)
inputDelegates = new List<EZInputDelegate>();
inputDelegates.Add(del);
}
/// <summary>
/// Removes a method added with AddInputDelegate().
/// </summary>
/// <param name="del">A method that conforms to the EZInputDelegate pattern.</param>
public virtual void RemoveInputDelegate(EZInputDelegate del)
{
if (inputDelegates != null)
inputDelegates.Remove(del);
if (inputDelegates.Count == 0)
inputDelegates = null;
}
public virtual void SetValueChangedDelegate(EZValueChangedDelegate del) {}
/// <summary>
/// Adds a method to be called when the value of a control changes (such as a checkbox changing from false to true, or a slider being moved).
/// </summary>
/// <param name="del">A method that conforms to the EZValueChangedDelegate pattern.</param>
public virtual void AddValueChangedDelegate(EZValueChangedDelegate del) {}
/// <summary>
/// Removes a method added with AddValueChangedDelegate().
/// </summary>
/// <param name="del">A method that conforms to the EZValueChangedDelegate pattern.</param>
public virtual void RemoveValueChangedDelegate(EZValueChangedDelegate del) {}
public void RunAction()
{
ActionsOnClick.RunAction(this.gameObject,null);
}
}
so in the instance of using the ScriptController, i can get to any of the variables/functions defined in the hotspot class, but accessing the ActionOnHelper variable (data class) and defining parameters within it eludes me.
Additionally i haven't quite figured out the EZGui integration but i'm assuming i can use the OnInput(POINTER_INFO ptr) public function in HotSpot and override that in the ScriptController? would it then pass in the ptr info to the HotSpot?
Thats a fairly generic example but it covers a TON of uses within how we have our tooling setup.
Thanks again for the help! Its greatly appreciated.
Cheers
Bryan