Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ObjectPools : MonoBehaviour
  6. {
  7. public CoinRotate Coin;
  8. private Queue<CoinRotate> Items = new Queue<CoinRotate>();
  9. public static ObjectPools Instance {get; set;}
  10. private void Awake(){
  11. //Instance = this;
  12. }
  13. public CoinRotate Get(){
  14. if(Items.Count == 0){
  15. CoinRotate obstacle = Instantiate(Coin);
  16. obstacle.gameObject.SetActive(false);
  17. Items.Enqueue(obstacle);
  18. }
  19. return Items.Dequeue();
  20. }
  21. public void ReturnToPool(CoinRotate obj){
  22. obj.gameObject.SetActive(false);
  23. Items.Enqueue(obj);
  24. }
  25. // Start is called before the first frame update
  26. void Start()
  27. {
  28.  
  29. }
  30.  
  31. // Update is called once per frame
  32. void Update()
  33. {
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement