Unselectable.cs 648 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.EventSystems;
  4. namespace SRF.UI
  5. {
  6. [AddComponentMenu("SRF/UI/Unselectable")]
  7. public sealed class Unselectable : SRMonoBehaviour, IEventSystemHandler, ISelectHandler
  8. {
  9. public void OnSelect(BaseEventData eventData)
  10. {
  11. this._suspectedSelected = true;
  12. }
  13. private void Update()
  14. {
  15. if (!this._suspectedSelected)
  16. {
  17. return;
  18. }
  19. if (EventSystem.current.currentSelectedGameObject == base.CachedGameObject)
  20. {
  21. EventSystem.current.SetSelectedGameObject(null);
  22. }
  23. this._suspectedSelected = false;
  24. }
  25. private bool _suspectedSelected;
  26. }
  27. }