Example #1
0
        /// <summary>
        /// 刷新红点数量
        /// </summary>
        /// <param name="self"></param>
        /// <param name="target"></param>
        /// <param name="Count"></param>
        public static void RefreshRedDotViewCount(this RedDotComponent self, string target, int Count)
        {
            if (!self.IsLeafNode(target))
            {
                Log.Error("can not refresh parent node view count");
                return;
            }

            self.RedDotMonoViewDict.TryGetValue(target, out Entity uiRedDotComponent);

            self.RetainViewCount[target] = Count;

            if (uiRedDotComponent != null)
            {
                UIEventSystem.Instance.OnChangeRedDotActive(uiRedDotComponent, self.RetainViewCount[target]);
            }

            bool isParentExist = self.ToParentDict.TryGetValue(target, out string parent);

            while (isParentExist)
            {
                var viewCount = 0;

                foreach (var childNode in self.RedDotNodeParentsDict[parent])
                {
                    viewCount += self.RetainViewCount[childNode];
                }

                self.RetainViewCount[parent] = viewCount;

                if (self.RedDotMonoViewDict.TryGetValue(parent, out uiRedDotComponent))
                {
                    UIEventSystem.Instance.OnChangeRedDotActive(uiRedDotComponent, viewCount);
                }

                isParentExist = self.ToParentDict.TryGetValue(parent, out parent);
            }
        }
Example #2
0
        /// <summary>
        /// 创建树————移除节点
        /// </summary>
        /// <param name="self"></param>
        /// <param name="target"></param>
        public static void RemoveRedDotNode(this RedDotComponent self, string target)
        {
            if (!self.ToParentDict.TryGetValue(target, out string parent))
            {
                return;
            }

            if (!self.IsLeafNode(target))
            {
                Log.Error("can not remove parent node!");
                return;
            }

            self.ToParentDict.Remove(target);
            if (!string.IsNullOrEmpty(parent))
            {
                self.RedDotNodeParentsDict[parent].Remove(target);
                if (self.RedDotNodeParentsDict[parent].Count <= 0)
                {
                    self.RedDotNodeParentsDict[parent].Dispose();
                    self.RedDotNodeParentsDict.Remove(parent);
                }
            }
        }