Example #1
0
        public static async void OnRefreshCount(this UIRedDotComponent self, int count)
        {
            if (!self.isRedDotActive && count > 0)
            {
                await self.ActivatingComponent();

                self.unity_target.gameObject.SetActive(true);
                self.isRedDotActive = true;
            }
            else if (self.isRedDotActive && count <= 0)
            {
                await self.ActivatingComponent();

                self.unity_target.gameObject.SetActive(false);
                self.isRedDotActive = false;
            }
        }
Example #2
0
        public static async ETTask ActivatingComponent(this UIRedDotComponent self)
        {
            if (self.unity_target == null)
            {
                self.unity_target = self.GetGameObject().GetComponentInChildren <RedDotMonoView>();
                if (self.unity_target == null)
                {
                    string path = "UI/UICommon/Prefabs/UIRedDot.prefab";
                    var    obj  = await GameObjectPoolComponent.Instance.GetGameObjectAsync(path);

                    self.TempObj = obj;
                    obj.transform.SetParent(self.GetTransform(), false);
                    obj.transform.localScale = self.Scaler;
                    obj.transform.GetComponent <RectTransform>().anchoredPosition = self.PositionOffset;
                    self.unity_target = obj.GetComponent <RedDotMonoView>();
                    if (self.unity_target == null)
                    {
                        Log.Error($"添加UI侧组件UIRedDotComponent时,物体{self.GetGameObject().name}上实例化{path}失败");
                    }
                }
            }
        }