MoveItem.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. #if UNITY_EDITOR
  6. using UnityEditor;
  7. #endif
  8. using System.Linq;
  9. using HighlightingSystem;
  10. public class MoveItem : MonoBehaviour
  11. {
  12. [LabelText("相对方向")]
  13. public Vector3 m_Direction = new Vector3(0, 0, 0);
  14. /// <summary>
  15. /// 使用世界坐标方向
  16. /// </summary>
  17. public bool m_UserGlobalDirection;
  18. [LabelText("运行时长")]
  19. public float m_Duration;
  20. public void OpenHighter(bool open)
  21. {
  22. HighlightingSystem.Highlighter highlighter = GetComponent<HighlightingSystem.Highlighter>() == null ? gameObject.AddComponent<HighlightingSystem.Highlighter>() : GetComponent<HighlightingSystem.Highlighter>();
  23. if (open)
  24. {
  25. highlighter.ConstantOn();
  26. }else
  27. {
  28. Destroy(highlighter);
  29. }
  30. }
  31. #if UNITY_EDITOR
  32. private void OnDrawGizmos()
  33. {
  34. DrawPathLine();
  35. }
  36. public void DrawPathLine()
  37. {
  38. if (Selection.gameObjects.Contains(this.gameObject))
  39. {
  40. Gizmos.color = Color.yellow;
  41. if (m_UserGlobalDirection)
  42. {
  43. Gizmos.DrawLine(transform.position, transform.position + m_Direction);
  44. }
  45. else
  46. {
  47. Gizmos.DrawLine(transform.position, transform.position + transform.TransformDirection(m_Direction));
  48. }
  49. }
  50. }
  51. #endif
  52. }