DemoController.cs 484 B

12345678910111213141516171819
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class DemoController : MonoBehaviour
  5. {
  6. [SerializeField] private GameObject[] m_Demos;
  7. private int _currentDemo;
  8. public void Move(int count)
  9. {
  10. m_Demos[_currentDemo].gameObject.SetActive(false);
  11. _currentDemo += count;
  12. if (_currentDemo < 0) _currentDemo = m_Demos.Length - 1;
  13. if (_currentDemo >= m_Demos.Length) _currentDemo = 0;
  14. m_Demos[_currentDemo].gameObject.SetActive(true);
  15. }
  16. }