using UnityEngine;
using System.Collections;
[AddComponentMenu("NGUI/Extensions/Cancel Key Simulate OnClick")]
public class CancelKeySimulateOnClick : MonoBehaviour {
public GameObject target;
public UICamera camera;
public GameObject [] selectionExceptions;
// Update is called once per frame
void Update () {
if (target != null && Input.GetKeyUp(camera.cancelKey0) || Input.GetKeyUp(camera.cancelKey1)) {
if (selectionExceptions.Length > 0) {
foreach (GameObject selection in selectionExceptions) {
if (selection == UICamera.selectedObject) {
return;
}
}
}
target.SendMessage("OnClick", SendMessageOptions.DontRequireReceiver);
}
}
}