From 22891bf59032ba88262824255a706d652031384b Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 10 Mar 2022 14:07:40 +0800 Subject: * move folder --- Assets/Tools/ActionTool/ActionToolGizmos.cs | 139 ---------------------------- 1 file changed, 139 deletions(-) delete mode 100644 Assets/Tools/ActionTool/ActionToolGizmos.cs (limited to 'Assets/Tools/ActionTool/ActionToolGizmos.cs') diff --git a/Assets/Tools/ActionTool/ActionToolGizmos.cs b/Assets/Tools/ActionTool/ActionToolGizmos.cs deleted file mode 100644 index 938d2c51..00000000 --- a/Assets/Tools/ActionTool/ActionToolGizmos.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -namespace ActionTool -{ - - public class ActionToolGizmos : MonoBehaviour - { - AnimationData m_AnimationData; - - AnimationClip m_Clip; - - AnimationClip clip - { - get - { - if (m_AnimationData == null) - return null; - if (m_Clip != null && m_Clip.name == m_AnimationData.animationName) - return m_Clip; - m_Clip = AssetDatabase.LoadAssetAtPath< AnimationClip>(m_AnimationData.animationPath); - return m_Clip; - } - } - - float m_CurAnimFrame; - - bool m_IsShowRootMotion; - - GameObject m_UnitRoot; - - public void Initialize(GameObject unitRoot) - { - m_UnitRoot = unitRoot; - } - - public void SetAnimationData(AnimationData data) - { - m_AnimationData = data; - } - - public void ShowRootMotionGizmos(bool show) - { - m_IsShowRootMotion = show; - } - - public void SetCurAnimFrame(float frame) - { - m_CurAnimFrame = frame; - } - - void OnDrawGizmos() - { - DrawRoot(); - DrawAxis(); - DrawColliders(); - - DrawRootMotion(); - } - - void DrawRoot() - { - Gizmos.color = Color.yellow; - Gizmos.DrawCube(m_UnitRoot.transform.position, new Vector3(0.1f, 0.1f, 0.1f)); - } - - void DrawAxis() - { - Gizmos.color = Color.red; - Gizmos.DrawLine(-Vector3.right * 1000, Vector3.right * 1000); - Gizmos.color = Color.green; - Gizmos.DrawLine(Vector3.zero, Vector3.up * 1000); - Gizmos.color = Color.blue; - Gizmos.DrawLine(Vector3.zero, Vector3.forward * 1000); - } - - void DrawColliders() - { - if (m_AnimationData == null) - return; - DrawBoxes(m_AnimationData.hurtBoxes, Color.green); - DrawBoxes(m_AnimationData.hitBoxes, Color.red); - } - - void DrawBoxes(List boxes, Color color) - { - if (boxes != null && boxes.Count > 0) - { - for (int i = 0; i < boxes.Count; ++i) - { - var box = boxes[i]; - if (box != null) - { - var info = box.GetColliderInfo(m_CurAnimFrame); - if (!info.active) - continue; - Vector3 pos = info.position; - switch (box.pivot) - { - case ColliderBox.Pivot.MiddleBottom: - pos.y += info.size.y / 2; - break; - } - pos += m_UnitRoot.transform.position; - Gizmos.color = color * 0.5f; - Gizmos.DrawCube(pos, info.size); - } - } - } - } - - void DrawRootMotion() - { - if (m_AnimationData == null) - return; - if (!m_AnimationData.overrideRootMotion) - return; - if (!m_IsShowRootMotion) - return; - if (clip == null) - return; - var rm = m_AnimationData.rootMotionOverrideData; - float frames = clip.length * AnimationData.FPS; - float step = 0.05f; - Vector3 prev = rm.GetPosition(0); - Vector3 cur = prev; - Gizmos.color = Color.white; - for (float f = step; f <= frames + step; f+= step) - { - cur = rm.GetPosition(f); - Gizmos.DrawLine(prev, cur); - prev = cur; - } - } - - } -} -- cgit v1.1-26-g67d0