Ejemplo n.º 1
0
        // 程序指定响应间隔
        public static EventTriggerClick Register(GameObject obj, System.Action <GameObject> callback, float clickInterval, bool isIgnoreDrag = true)
        {
            EventTriggerClick listen = Register(obj, callback, isIgnoreDrag);

            if (listen != null)
            {
                listen.m_requireInterval = clickInterval;
            }
            return(listen);
        }
Ejemplo n.º 2
0
        public static void RegisterButtonClick(GameObject obj, Action <GameObject> func, bool isIgnoreDrag = true)
        {
            if (obj == null)
            {
#if UNITY_EDITOR
                Debug.LogError("RegisterButtonClick : obj is Null");
#endif
                return;
            }
            EventTriggerClick.Register(obj, func, isIgnoreDrag);
        }
Ejemplo n.º 3
0
        // 可以在 Prefab 上挂脚本指定时间
        public static EventTriggerClick Register(GameObject obj, System.Action <GameObject> callback, bool isIgnoreDrag = true)
        {
            if (obj == null)
            {
                Debug.LogError("GetEventTrigger paramer is null!!!");
                return(null);
            }

            EventTriggerClick listen = Global.AddComponentIfNotExist <EventTriggerClick>(obj);

            if (listen != null)
            {
                listen.onClick      = callback;
                listen.isIgnoreDrag = isIgnoreDrag;
            }
            return(listen);
        }
Ejemplo n.º 4
0
        // 获取点击响应组件(没有会自动创建)
        public static EventTriggerClick GetEventTrigger(GameObject obj, bool isToCreate = true)
        {
            if (obj == null)
            {
                Debug.LogError("GetEventTrigger paramer is null!!!");
                return(null);
            }
            EventTriggerClick listen = obj.GetComponent <EventTriggerClick>();

            if (listen == null && isToCreate)
            {
                object objs = new object();
                lock (objs)
                {
                    EventTriggerClick retlisten = obj.AddComponent <EventTriggerClick>();
                    return(retlisten);
                }
            }
            return(listen);
        }
Ejemplo n.º 5
0
        public static void UnRegisterButtonClick(GameObject gobj, bool destroyImmediately)
        {
            if (gobj == null)
            {
                Debug.LogWarningFormat("EventTriggerClick.UnRegisterButtonClick param gobj is null.");
                return;
            }

            EventTriggerClick eventclick = gobj.GetComponent <EventTriggerClick>();

            if (eventclick != null)
            {
                eventclick.onClick = null;
                if (destroyImmediately)
                {
                    GameObject.DestroyImmediate(eventclick);
                }
                else
                {
                    GameObject.Destroy(eventclick);
                }
            }
        }