unity查找同一层级下同名物体

public class Testinput : MonoBehaviour {
    GameObject go;
    List gos = new List();
	// Use this for initialization
	void Start () {
        int i = 1;
        while (true)
        {
           
            go = GameObject.Find("GameObject");
           
            if (go)
            {
                go.name = i.ToString();
                gos.Add(go);
                i++;
            }    
            else
            {
                break;
            }

            print(i);
        }

        foreach (var item in gos)
        {
            item.name = "GameObject";
        }

        print(gos.Count);
    }

   
   
}

 

你可能感兴趣的:(总栏目)