Example #1
0
        protected static void RegisterEventClickExit(GameObject go, Action <PointerEventData> handle)
        {
            if (null == go || null == handle)
            {
                return;
            }

            PointerEventListener.GetOrAdd(go).onExit = handle;
        }
Example #2
0
        protected static void RegisterEventClick(Component comp, Action <PointerEventData> handle)
        {
            if (null == comp || null == handle)
            {
                return;
            }

            PointerEventListener.GetOrAdd(comp.gameObject).onClick = handle;
        }
Example #3
0
        private void ConfigureRedDot(GameObject objRef, string name, int count, bool clickClear = false)
        {
            var redDot = objRef.GetComponentInChildren <RedDotRef>(true);

            if (!redDot)
            {
                return;
            }

            if (!redDot.Events.Contains(name))
            {
                redDot.Events.Add(name);
            }
            redDot.SetActive(true);

            if (clickClear)
            {
                var pointer = PointerEventListener.GetOrAdd(objRef.gameObject);
                pointer.onClick += _ =>
                {
                    var invocation = pointer.onClick.GetInvocationList().FirstOrDefault(d => d.Method.ReflectedType.DeclaringType == typeof(RedDotSystem));
                    if (invocation == null)
                    {
                        return;
                    }
                    ClearEvent(name);
                    pointer.onClick -= (Action <PointerEventData>)invocation;
                };
            }

            var textComp = redDot.GetComponentInChildren <Text>();

            if (!textComp)
            {
                return;
            }

            textComp.text = count > 0 ? count.ToString() : string.Empty;
        }