SwitchObject.cs 565 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace BasicTools
  5. {
  6. public class SwitchObject : MonoBehaviour
  7. {
  8. private void Start()
  9. {
  10. }
  11. private void Update()
  12. {
  13. }
  14. private void OnGUI()
  15. {
  16. for (int i = 0; i < this.objs.Count; i++)
  17. {
  18. if (GUI.Button(new Rect(700f, (float)(100 * i + 100), 200f, 50f), (!this.objs[i].activeSelf) ? ("打开" + this.objs[i].name) : "关闭"))
  19. {
  20. this.objs[i].SetActive(this.objs[i].activeSelf);
  21. }
  22. }
  23. }
  24. public List<GameObject> objs;
  25. }
  26. }