EnableSwitch.cs 409 B

123456789101112131415161718192021
  1. using System;
  2. using UnityEngine;
  3. public class EnableSwitch : MonoBehaviour
  4. {
  5. public bool SetActive(int target)
  6. {
  7. if (target < 0 || target >= this.SwitchTargets.Length)
  8. {
  9. return false;
  10. }
  11. for (int i = 0; i < this.SwitchTargets.Length; i++)
  12. {
  13. this.SwitchTargets[i].SetActive(false);
  14. }
  15. this.SwitchTargets[target].SetActive(true);
  16. return true;
  17. }
  18. public GameObject[] SwitchTargets;
  19. }