コード例 #1
0
        public static void AddClickListener(this GameObject go, float x, float y, float z, float height, UnityAction callback)
        {
            EventObject eventObject = go.transform.GetComponent <EventObject>();

            if (eventObject == null)
            {
                eventObject = go.transform.gameObject.AddComponent <EventObject>();
            }
            eventObject.SetColliderSize(x, y, z, height);
            eventObject.AddClickListener(callback);
        }
コード例 #2
0
        public static void AddClickListener(this GameObject go, UnityAction callback)
        {
            //EventTrigger trigger = go.transform.GetComponent<EventTrigger>();
            //if (trigger == null)
            //{
            //	trigger = go.transform.gameObject.AddComponent<EventTrigger>();
            //	trigger.triggers = new List<EventTrigger.Entry>();
            //}

            //EventTrigger.Entry entry = new EventTrigger.Entry();
            //entry.eventID = EventTriggerType.PointerDown;
            //UnityAction<BaseEventData> callback1 = new UnityAction<BaseEventData>(eventData => callback());
            //entry.callback.AddListener(callback1);
            //trigger.triggers.Add(entry);
            EventObject eventObject = go.transform.GetComponent <EventObject>();

            if (eventObject == null)
            {
                eventObject = go.transform.gameObject.AddComponent <EventObject>();
            }
            eventObject.AddClickListener(callback);
        }