I want to create events and then, functions which are subscribed to the event can access information about the event. For example, in Class 2 below, I want it to be able to access things such as touch.position, etc.
Class 1:
public delegate void TouchEventHandler (object sender,EventArgs e);
public event TouchEventHandler TouchBegan;
public Vector2 touchPosition;
void Update ()
{
if (Input.touchCount > 0) {
for (int i = 0; i < Input.touchCount; i++) {
Touch touch = Input.GetTouch (i);
if (touch.phase == TouchPhase.Began) {
TouchEventHandler touchBegan = TouchBegan;
if (touchBegan != null)
touchBegan (this, e);
}
}}
Class 2:
void OnTouchBegan (EventArgs e)
{
Debug.Log ("Ran");
}