예제 #1
0
    public static Transform FindTransformAtIndexPath(string indexPath, Transform root)
    {
        if (string.IsNullOrEmpty(indexPath))
        {
            return(root);
        }

        int       tIndex;
        Transform t;
        string    rPath;

        if (indexPath.Contains('/'))
        {
            string[] pathData = indexPath.Split('/');
            tIndex = int.Parse(pathData[0]);
            rPath  = KSPUtil.PrintCollection(pathData.Skip(1), "/");


            t = root.GetChild(tIndex);
            return(FindTransformAtIndexPath(rPath, t));
        }
        else
        {
            tIndex = int.Parse(indexPath);
            return(root.GetChild(tIndex));
        }
    }