DeleteVisible.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class DeleteVisible : MonoBehaviour
  7. {
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. }
  12. // Update is called once per frame
  13. void Update()
  14. {
  15. }
  16. public void setDeleteVisible() {
  17. GameObject parent = GameObject.Find("Canvas");
  18. Transform[] children = parent.GetComponentsInChildren<Transform>(true);
  19. foreach(Transform ch in children)
  20. {
  21. if(ch.gameObject.name == "DeleteButton")
  22. {
  23. ch.gameObject.SetActive(true);
  24. }
  25. }
  26. }
  27. public void setDeleteNonVisible() {
  28. GameObject parent = GameObject.Find("Canvas");
  29. Transform[] children = parent.GetComponentsInChildren<Transform>(true);
  30. foreach(Transform ch in children)
  31. {
  32. if(ch.gameObject.name == "DeleteButton")
  33. {
  34. ch.gameObject.SetActive(false);
  35. }
  36. }
  37. }
  38. }