Beispiel #1
0
        public Transform SearchChild(string name, GameObject root)
        {
            XBoneTree child = SearchTree(name);

            if (child != null)
            {
                int    index = child.cname.IndexOf("/");
                string path  = child.cname.Substring(index + 1);
                return(root.transform.Find(path));
            }
            return(null);
        }
Beispiel #2
0
        public void FillChilds(Transform transf)
        {
            int cnt = transf.childCount;

            childs = new XBoneTree[cnt];
            for (int i = 0; i < cnt; i++)
            {
                Transform child = transf.GetChild(i);
                childs[i] = new XBoneTree(cname, child.name, depth + 1);
                childs[i].FillChilds(child);
            }
        }
Beispiel #3
0
        public static Transform[] Str2Transf(string[] str, GameObject go)
        {
            if (str != null && go != null)
            {
                XBoneTree tree = new XBoneTree(string.Empty, go.name, 0);
                tree.FillChilds(go.transform);

                Transform[] rst = new Transform[str.Length];
                for (int i = 0; i < str.Length; i++)
                {
                    var child = tree.SearchChild(str[i], go);
                    rst[i] = child;
                }
                return(rst);
            }
            return(null);
        }