Exemplo n.º 1
0
 private string GetRelativePath(AutoGeneratePath root, AutoGeneratePath me)
 {
     if (root == me)
     {
         return(null);
     }
     else
     {
         string str = Recursion(root.transform, me.transform, "");
         if (str[0] == '/')
         {
             str = str.Substring(1);
         }
         return(str);
     }
 }
Exemplo n.º 2
0
        public AutoGeneratePath[] GetAllAutoGeneratePath()
        {
            List <AutoGeneratePath> list = new List <AutoGeneratePath>();

            //先找自身的
            AutoGeneratePath[] paths = transform.GetComponents <AutoGeneratePath>();
            if (paths != null)
            {
                for (int i = 0; i < paths.Length; i++)
                {
                    AutoGeneratePath path = paths[i];
                    if (path.type == UIType.Root)
                    {
                        list.Add(path);
                    }
                }
            }
            //找儿子的
            FindChildAutoGeneratePath(transform, list);
            return(list.ToArray());
        }
Exemplo n.º 3
0
        public void FindChildAutoGeneratePath(Transform tas, List <AutoGeneratePath> list)
        {
            for (int i = 0; i < tas.childCount; i++)
            {
                Transform          temp  = tas.GetChild(i);
                AutoGeneratePath[] paths = temp.GetComponents <AutoGeneratePath>();
                if (paths == null || paths.Length == 0)
                {
                    FindChildAutoGeneratePath(temp, list);
                }
                else
                {
                    bool isFind = true;
                    for (int j = 0; j < paths.Length; j++)
                    {
                        AutoGeneratePath path = paths[j];
                        if (path.type == UIType.Root)
                        {
                            isFind = false;
                        }
                    }

                    for (int j = 0; j < paths.Length; j++)
                    {
                        AutoGeneratePath path = paths[j];
                        if (path.type == UIType.Child)
                        {
                            list.Add(path);
                        }

                        if (path.type == UIType.Child && isFind)
                        {
                            FindChildAutoGeneratePath(temp, list);
                        }
                    }
                }
            }
        }