CircleTargetView.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // MIT License
  2. // https://gitlab.com/ilnprj
  3. // Copyright (c) 2020 ilnprj
  4. using UnityEngine;
  5. namespace RadarComponents
  6. {
  7. /// <summary>
  8. /// View for circle compass
  9. /// </summary>
  10. public class CircleTargetView : BaseTargetView
  11. {
  12. private GameObject lookingObject;
  13. private Transform looking;
  14. private Transform target;
  15. protected override void Awake()
  16. {
  17. base.Awake();
  18. lookingObject = new GameObject();
  19. lookingObject.transform.SetParent(locator.transform);
  20. looking = lookingObject.transform;
  21. looking.localPosition = Vector3.zero;
  22. looking.localRotation = Quaternion.identity;
  23. }
  24. private void Start()
  25. {
  26. lookingObject.name = CurrentTarget.IdTarget;
  27. UpdateViewTarget();
  28. }
  29. public override void UpdateViewTarget()
  30. {
  31. if (targetTransform!=null)
  32. {
  33. looking.LookAt(targetTransform);
  34. transform.localRotation = Quaternion.Euler(0, 0, -looking.transform.eulerAngles.y);
  35. UpdateExtensions();
  36. }
  37. }
  38. }
  39. }