static int RecursiveGetChildCount(this GameObjectPoolComponent self, Transform trans, string path, ref Dictionary <string, int> record) { int total_child_count = trans.childCount; for (int i = 0; i < trans.childCount; i++) { var child = trans.GetChild(i); if (child.name.Contains("Input Caret") || child.name.Contains("TMP SubMeshUI") || child.name.Contains("TMP UI SubObject") || /*child.GetComponent<LoopListViewItem2>()!=null || child.GetComponent<LoopGridViewItem>() != null ||*/(child.name.Contains("Caret") && child.parent.name.Contains("Text Area"))) { //Input控件在运行时会自动生成个光标子控件,而prefab中是没有的,所以得过滤掉 //TextMesh会生成相应字体子控件 //TextMeshInput控件在运行时会自动生成个光标子控件,而prefab中是没有的,所以得过滤掉 total_child_count = total_child_count - 1; } else { string cpath = path + "/" + child.name; if (record.ContainsKey(cpath)) { record[cpath] += 1; } else { record[cpath] = 1; } total_child_count += self.RecursiveGetChildCount(child, cpath, ref record); } } return(total_child_count); }
static async ETTask __CheckAfter(this GameObjectPoolComponent self, string path, GameObject inst) { await TimerComponent.Instance.WaitAsync(2000); if (inst != null && inst.transform != null && self.__CheckInstIsInPool(path, inst)) { var go_child_count = self.__goChildsCountPool[path]; Dictionary <string, int> childsCountMap = new Dictionary <string, int>(); int inst_child_count = self.RecursiveGetChildCount(inst.transform, "", ref childsCountMap); if (go_child_count != inst_child_count) { Log.Error($"go_child_count({ go_child_count }) must equip inst_child_count({inst_child_count}) path = {path} "); foreach (var item in childsCountMap) { var k = item.Key; var v = item.Value; var unfair = false; if (!self.__detailGoChildsCount[path].ContainsKey(k)) { unfair = true; } else if (self.__detailGoChildsCount[path][k] != v) { unfair = true; } if (unfair) { Log.Error($"not match path on checkrecycle = { k}, count = {v}"); } } } } }
static void __InitGoChildCount(this GameObjectPoolComponent self, string path, GameObject go) { if (!self.__IsOpenCheck()) { return; } if (!self.__goChildsCountPool.ContainsKey(path)) { Dictionary <string, int> childsCountMap = new Dictionary <string, int>(); int total_child_count = self.RecursiveGetChildCount(go.transform, "", ref childsCountMap); self.__goChildsCountPool[path] = total_child_count; self.__detailGoChildsCount[path] = childsCountMap; } }