获取Points下的子路点:
两种方法
方法1:
tearsGo = Rescources.Load<GameObject>("Prefabs/Tear");
transform.Find("Points").GetChild(0);
transform.Find("Points").GetChild(0-n);
方法2:定义一个数组,存放子路点
private Transform[] pointsTrans;
void Start(){
tearsGo = Rescources.Load<GameObject>("Prefabs/Tear");//加载资源预制体
Transform pointTrans = trans.Find("Points");
//寻找父路点
pointsTrans = new Transform[pointTrans.childCount];//初始化路点数组,数组大小是父节点的数目
for(int i=0;i<pointsTrans.Length;i++)
{
//把子路点加进去
pointsTrans[i] = pointsTrans.getChild(i);
}
foreach(var item in pointsTrans)
{
Debug.Log(item);
}
}