Exemplo n.º 1
0
 private void OnGUI()
 {
     if (GUILayout.Button("Active Object(Sphere)"))
     {
         UnityObjectPool pool = PoolManager.Instance.GetPool("Sphere");
         GameObject      go   = pool.Get();
         go.SetActive(true);
     }
     if (GUILayout.Button("Active Object(Cube)"))
     {
         UnityObjectPool pool = PoolManager.Instance.GetPool("Cube");
         GameObject      go   = pool.Get();
         go.SetActive(true);
         Timer.Startup(3, (t) => {
             pool.Recycle(go);
         });
     }
     if (GUILayout.Button("Active Object(Capsule)"))
     {
         UnityObjectPool pool = PoolManager.Instance.GetPool("Capsule");
         GameObject      go   = pool.Get();
         go.SetActive(true);
         Timer.Startup(3, (t) => {
             pool.Recycle(go);
         });
     }
     if (GUILayout.Button("Release Pool(Group:NoCapsule)"))
     {
         PoolManager.Instance.ReleasePoolsByGroup("NoCapsule", true);
     }
     if (GUILayout.Button("Release Pool(Group:Default)"))
     {
         PoolManager.Instance.ReleasePoolsByDefaultGroup();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 让对象池回收这个对象
 /// </summary>
 public void Recycle()
 {
     ReleaseTimer();
     if (pool == null || !pool.Recycle(this.gameObject))
     {
         DestroySignObject();
     }
 }