public void OnGUI() { if (GUILayout.Button("创建")) { for (int i = 0; i < 3; i++) { Vector3 pos = new Vector3(Random.Range(-5, 5), 0, Random.Range(-5, 5)); poolobj.CreateObject(names[0], prefabs[0], pos, Quaternion.identity); } } if (GUILayout.Button("回收")) { var go = GameObject.FindGameObjectWithTag(names[0]); print(go); if (go != null) { poolobj.CollectObject(go); } } if (GUILayout.Button("全部回收")) { poolobj.ClearAll(); } }
private void OnGUI() { if (GUILayout.Button("创建")) { for (int i = 0; i < 2; i++) { Vector3 obj_pos = new Vector3(Random.Range(-10, 10), 0, Random.Range(-10, 10)); gop.CreateObject(Objnm[i], prefabObj[i], obj_pos, Quaternion.identity); } } if (GUILayout.Button("释放")) { gop.Clear("Cube"); } if (GUILayout.Button("实时回收")) { gop.CollectObject(GameObject.FindGameObjectWithTag("Cube")); } if (GUILayout.Button("延时回收")) { gop.CollectObject(GameObject.FindGameObjectWithTag("Cube"), 5.0f); } }
// Update is called once per frame void OnGUI() { if (GUILayout.Button("创建")) { Vector3 pos1 = new Vector3(Random.Range(-10, 10), 0, Random.Range(-10, 10)); poolobj.CreateObject(names[0], prefabs[0], pos1, Quaternion.identity); } if (GUILayout.Button("释放 ,彻底删除")) { poolobj.ClearAll(); } if (GUILayout.Button("回收")) { //找到某一个,回收 var go = GameObject.FindGameObjectWithTag(names[0]); if (go != null) { poolobj.CollectObject(go); } } }