using System; using System.Collections.Generic; using UnityEngine; public class CMT { public static Transform SearchObjName(Transform t, string name, bool boSMPass = true) { string name2 = t.name; if (boSMPass && name2.Contains("_SM_")) { return null; } if (name == "_ROOT_") { return t; } if (name2 == name) { return t; } for (int i = 0; i < t.childCount; i++) { Transform child = t.GetChild(i); Transform transform = CMT.SearchObjName(child, name, boSMPass); if (transform != null) { return transform; } } return null; } public static void SearchAndAddObj(Transform t, Dictionary dic) { string name = t.name; if (name.Contains("_SM_")) { return; } dic[name] = t; for (int i = 0; i < t.childCount; i++) { CMT.SearchAndAddObj(t.GetChild(i), dic); } } public static Transform SearchObjObj(Transform tParent, Transform tSearch) { if (tParent == tSearch) { return tSearch; } for (int i = 0; i < tParent.childCount; i++) { Transform child = tParent.GetChild(i); Transform transform = CMT.SearchObjObj(child, tSearch); if (transform != null) { return transform; } } return null; } public static void BindTrans(List listPosRot, List listScl, Dictionary body1, Transform t) { Transform item; if (body1.TryGetValue(t.name, out item)) { listPosRot.Add(t); listPosRot.Add(item); if (t.name == "Mune_L" || t.name == "Mune_R") { listScl.Add(t); listScl.Add(item); } } for (int i = 0; i < t.childCount; i++) { CMT.BindTrans(listPosRot, listScl, body1, t.GetChild(i)); } } public static void TestTrans(Transform t) { t.localRotation = Quaternion.identity; for (int i = 0; i < t.childCount; i++) { CMT.TestTrans(t.GetChild(i)); } } public static void SetActiveFlag(Transform t, bool bo) { for (int i = 0; i < t.childCount; i++) { Transform child = t.GetChild(i); CMT.SetActiveFlag(child, bo); child.gameObject.SetActive(bo); } t.gameObject.SetActive(bo); } public static Transform SearchObjNameContainsLower(Transform t, string name, bool bIgnoreCase = false) { string name2 = t.name; if ((!bIgnoreCase) ? name2.Contains(name) : name2.ToLower().Contains(name)) { return t; } for (int i = 0; i < t.childCount; i++) { Transform child = t.GetChild(i); Transform transform = CMT.SearchObjNameContainsLower(child, name, bIgnoreCase); if (transform != null) { return transform; } } return null; } }