public delegate MouseOrTouch GetMouseDelegate (int button);
public delegate MouseOrTouch GetTouchDelegate (int id, bool createIfMissing);
public delegate void RemoveTouchDelegate (int id);
/// <summary>
/// Get the details of the specified mouse button.
/// </summary>
static public GetMouseDelegate GetMouse = delegate(int button) { return mMouse[button]; };
/// <summary>
/// Get or create a touch event. If you are trying to iterate through a list of active touches, use activeTouches instead.
/// </summary>
static public GetTouchDelegate GetTouch = delegate(int id, bool createIfMissing)
{
if (id < 0) return GetMouse(-id - 1);
for (int i = 0, imax = mTouchIDs.Count; i < imax; ++i)
if (mTouchIDs[i] == id) return activeTouches[i];
if (createIfMissing)
{
MouseOrTouch touch
= new MouseOrTouch
(); touch.pressTime = RealTime.time;
touch.touchBegan = true;
activeTouches.Add(touch);
mTouchIDs.Add(id);
return touch;
}
return null;
};
/// <summary>
/// Remove a touch event from the list.
/// </summary>
static public RemoveTouchDelegate RemoveTouch = delegate(int id)
{
for (int i = 0, imax = mTouchIDs.Count; i < imax; ++i)
{
if (mTouchIDs[i] == id)
{
mTouchIDs.RemoveAt(i);
activeTouches.RemoveAt(i);
return;
}
}
};