No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OverdrawControl.cs 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class OverdrawControl : MonoBehaviour
  6. {
  7. public int objectCount = 10;
  8. public Vector3 origin;
  9. public Vector3 offset;
  10. public GameObject prefab;
  11. public Text overdrawText;
  12. private int activeCount;
  13. private GameObject[] instances;
  14. void Start()
  15. {
  16. instances = new GameObject[objectCount];
  17. for (int i = 0; i < objectCount; ++i)
  18. instances[i] = Instantiate(prefab, origin + offset * i, Quaternion.identity);
  19. activeCount = objectCount;
  20. overdrawText.text = "Overdraw: x" + activeCount;
  21. }
  22. public void Increase()
  23. {
  24. if (activeCount < objectCount)
  25. {
  26. instances[activeCount].SetActive(true);
  27. activeCount++;
  28. overdrawText.text = "Overdraw: x" + activeCount;
  29. Debug.Log("Increase");
  30. }
  31. }
  32. public void Decrease()
  33. {
  34. if (activeCount > 0)
  35. {
  36. activeCount--;
  37. instances[activeCount].SetActive(false);
  38. overdrawText.text = "Overdraw: x" + activeCount;
  39. Debug.Log("Decrease");
  40. }
  41. }
  42. }