void Update() { //if (Input.GetKeyDown(KeyCode.C)) packSample = new Packdata(); //if (Input.GetKeyDown(KeyCode.D)) //{ // packSample.error = 99; // packSample = null; //} if (Random.Range(0, 2) == 0) { PackData _packet = ClassPoolT <PackData> .Dequeue(); _packet.PlusCount(); list.Add(_packet); } else if (list.Count > 0) { ClassPoolT <PackData> .Enqueue(list[0]); list.RemoveAt(0); } Debug.Log(list.Count + ":" + ClassPoolT <PackData> .queue.Count); }
void Fun1() { PackData _packet; int _rr = 0; for (int i = 0; i < LOOP_MAX; i++) { //int _rand = Random.Range(0, 2); int _rand = _rr++ % 2; if (_rand == 0) { _packet = new PackData(); _packet.PlusCount(); list.Add(_packet); } else if (list.Count > 0) { list.RemoveAt(0); } } //Debug.Log(list.Count + ":" + ObjectPool<PackData>.queue.Count); }