123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- using System.Linq;
- using HighlightingSystem;
- public class MoveItem : MonoBehaviour
- {
- [HideIf("m_IsHighterHide")]
- [LabelText("相对方向")]
- public Vector3 m_Direction = new Vector3(0, 0, 0);
- [HideIf("m_IsHighterHide")]
- /// <summary>
- /// 使用世界坐标方向
- /// </summary>
- public bool m_UserGlobalDirection;
- [LabelText("运行时长")]
- public float m_Duration;
- [OnValueChanged("IsHighterHideValueChange")]
- [LabelText("高亮闪烁隐藏")]
- public bool m_IsHighterHide;
- private Vector3 m_CacheDirection = Vector3.zero;
- private void IsHighterHideValueChange(bool result)
- {
- if (result)
- {
- m_CacheDirection = m_Direction;
- m_Direction = Vector3.zero;
- }
- else
- {
- m_Direction = m_CacheDirection;
- }
- }
- public void OpenHighter(bool open)
- {
- HighlightingSystem.Highlighter highlighter = GetComponent<HighlightingSystem.Highlighter>() == null ? gameObject.AddComponent<HighlightingSystem.Highlighter>() : GetComponent<HighlightingSystem.Highlighter>();
- if (open)
- {
- if (m_IsHighterHide)
- {
- highlighter.FlashingOn(Color.green, Color.yellow,4f);
- }
- else
- {
- highlighter.ConstantOn();
- }
- }else
- {
- Destroy(highlighter);
- }
- }
- /// <summary>
- /// 设置初始状态
- /// </summary>
- /// <param name="position"></param>
- public void SetInitState(Vector3 position)
- {
- transform.position = position;
- }
- /// <summary>
- /// 设置最终状态
- /// </summary>
- public void SetFianlState()
- {
- if (m_UserGlobalDirection)
- {
- transform.position = transform.position + m_Direction;
- }else
- {
- transform.position = transform.position + transform.TransformDirection(m_Direction);
- }
- }
- #if UNITY_EDITOR
- private void OnDrawGizmos()
- {
- DrawPathLine();
- }
- public void DrawPathLine()
- {
- if (Selection.gameObjects.Contains(this.gameObject))
- {
- Gizmos.color = Color.yellow;
- if (m_UserGlobalDirection)
- {
- Gizmos.DrawLine(transform.position, transform.position + m_Direction);
- }
- else
- {
- Gizmos.DrawLine(transform.position, transform.position + transform.TransformDirection(m_Direction));
- }
- }
- }
- #endif
- }
|