HorizontalCompass.cs 741 B

12345678910111213141516171819202122232425262728293031323334
  1. // MIT License
  2. // https://gitlab.com/ilnprj
  3. // Copyright (c) 2020 ilnprj
  4. using UnityEngine.UI;
  5. using UnityEngine;
  6. namespace RadarComponents
  7. {
  8. /// <summary>
  9. /// Simple scroller with compass
  10. /// </summary>
  11. [RequireComponent(typeof(RawImage))]
  12. public class HorizontalCompass : AbstractRadar
  13. {
  14. private RawImage compassImage;
  15. protected override void Awake()
  16. {
  17. compassImage = GetComponent<RawImage>();
  18. base.Awake();
  19. }
  20. public override void OnUpdateRadar()
  21. {
  22. if (locator != null)
  23. {
  24. compassImage.uvRect = new Rect(locator.transform.localEulerAngles.y / 360f, 0f, 1f, 1f);
  25. }
  26. }
  27. }
  28. }