diff options
12 files changed, 262 insertions, 38 deletions
diff --git a/Assets/ActionTool/Editor/ActionData.cs b/Assets/ActionTool/Editor/ActionData.cs index 936bc422..6993b378 100644 --- a/Assets/ActionTool/Editor/ActionData.cs +++ b/Assets/ActionTool/Editor/ActionData.cs @@ -57,8 +57,17 @@ namespace ActionTool private const string kStateName = "Action";
+ public RootMotionData rootMotion { get{ return m_RootMotion; } }
private RootMotionData m_RootMotion;
+ public string rootMotionPath
+ {
+ get
+ {
+ return AssetDatabase.GetAssetPath(m_RootMotion);
+ }
+ }
+
public void Initialize(Animator animator, AnimationClip clip, RootMotionData rootmotion)
{
m_Animator = animator;
diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs index 98c0245b..dc855fad 100644 --- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs +++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs @@ -234,19 +234,45 @@ namespace ActionTool y += 15;
GUI.Label(new Rect(xl, y, 105, 15), "AnimationData:", styles.textMiddle);
- width = styles.textMiddleBold.CalcSize(new GUIContent(ActionManager.AnimationDataPath)).x;
- GUI.Label(new Rect(xr, y, width, 15), ActionManager.AnimationDataPath, styles.textMiddleBold);
- if (GUI.Button(new Rect(xr + width + 10, y, 50, 15), "Info"))
- {
- AnimationData animData = ActionManager.animationData;
- ActionInfoEditor.ShowContent("AnimationData Info",
- "Events: " + (animData.animationEvents == null ? 0 : animData.animationEvents.Count )+ "\n" +
- "HurtBoxes: " + (animData.hurtBoxes == null ? 0 : animData.hurtBoxes.Count) + "\n" +
- "HitBoxes: " + (animData.hitBoxes == null ? 0 : animData.hitBoxes.Count) + "\n" +
- "ThrowBoxes: " + (animData.throwBoxes == null ? 0 : animData.throwBoxes.Count) + "\n" +
- "BlockBoxes: " + (animData.blockBoxes == null ? 0 : animData.blockBoxes.Count) + "\n" +
- "DefendBoxes: " + (animData.defendBoxes == null ? 0 : animData.defendBoxes.Count)
- );
+ if(ActionManager.animationData != null)
+ {
+ width = styles.textMiddleBold.CalcSize(new GUIContent(ActionManager.AnimationDataPath)).x;
+ GUI.Label(new Rect(xr, y, width, 15), ActionManager.AnimationDataPath, styles.textMiddleBold);
+ if (GUI.Button(new Rect(xr + width + 10, y, 50, 15), "Info"))
+ {
+ AnimationData animData = ActionManager.animationData;
+ ActionInfoEditor.ShowContent("AnimationData Info",
+ "Events: " + (animData.animationEvents == null ? 0 : animData.animationEvents.Count) + "\n" +
+ "HurtBoxes: " + (animData.hurtBoxes == null ? 0 : animData.hurtBoxes.Count) + "\n" +
+ "HitBoxes: " + (animData.hitBoxes == null ? 0 : animData.hitBoxes.Count) + "\n" +
+ "ThrowBoxes: " + (animData.throwBoxes == null ? 0 : animData.throwBoxes.Count) + "\n" +
+ "BlockBoxes: " + (animData.blockBoxes == null ? 0 : animData.blockBoxes.Count) + "\n" +
+ "DefendBoxes: " + (animData.defendBoxes == null ? 0 : animData.defendBoxes.Count)
+ );
+ }
+ }
+ else
+ {
+ GUI.Label(new Rect(xr, y, 100, 15), "None", styles.textMiddleBold);
+ }
+ y += 15;
+
+ GUI.Label(new Rect(xl, y, 105, 15), "RootMotion:", styles.textMiddle);
+ if(ActionManager.actionData.rootMotion != null)
+ {
+ width = styles.textMiddleBold.CalcSize(new GUIContent(ActionManager.actionData.rootMotionPath)).x;
+ GUI.Label(new Rect(xr, y, width, 15), ActionManager.actionData.rootMotionPath, styles.textMiddleBold);
+ if (GUI.Button(new Rect(xr + width + 10, y, 50, 15), "Info"))
+ {
+ RootMotionData rootMotion = ActionManager.actionData.rootMotion;
+ ActionInfoEditor.ShowContent("RootMotion Info",
+ "Frame Count: " + rootMotion.frameCount
+ );
+ }
+ }
+ else
+ {
+ GUI.Label(new Rect(xr, y, 100, 15), "None", styles.textMiddleBold);
}
y += 15;
@@ -299,8 +325,8 @@ namespace ActionTool float contentHeight = ActionManager.eventAndBoxCount * kFrameHeight + 40;
Rect content = new Rect(0, 0, action.totalFrame * kFrameWidth + 30, contentHeight);
float height = 300;
- if (position.height - kTimeLineViewYOffset > contentHeight)
- height = contentHeight;
+ if (position.height - kTimeLineViewYOffset > contentHeight + 15)
+ height = contentHeight + 15;
else
height = position.height - kTimeLineViewYOffset;
Rect viewport = new Rect(0, y, position.width, height);
diff --git a/Assets/Bundle/Unit/PC/Erika/AnimationData/Air_Combo03_Z0_4.asset b/Assets/Bundle/Unit/PC/Erika/AnimationData/Air_Combo03_Z0_4.asset index 95993aa8..cfd7918c 100644 --- a/Assets/Bundle/Unit/PC/Erika/AnimationData/Air_Combo03_Z0_4.asset +++ b/Assets/Bundle/Unit/PC/Erika/AnimationData/Air_Combo03_Z0_4.asset @@ -10,7 +10,7 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: cab6406109041434e890f22d6455172f, type: 3} - m_Name: Air_Combo03_Z0_4(Clone) + m_Name: Air_Combo03_Z0_4 m_EditorClassIdentifier: animationName: Air_Combo03_Z0_4 animationPath: Assets/Bundle/Unit/PC/Erika/AnimationClip/Air_Combo03_Z0_4.anim diff --git a/Assets/Bundle/Unit/PC/Erika/AnimationData/Combo4.asset b/Assets/Bundle/Unit/PC/Erika/AnimationData/Combo4.asset new file mode 100644 index 00000000..1b399978 --- /dev/null +++ b/Assets/Bundle/Unit/PC/Erika/AnimationData/Combo4.asset @@ -0,0 +1,46 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cab6406109041434e890f22d6455172f, type: 3} + m_Name: Combo4 + m_EditorClassIdentifier: + animationName: Combo4 + animationPath: Assets/Bundle/Unit/PC/Erika/AnimationClip/Combo4.anim + animationEvents: [] + hurtBoxes: [] + hitBoxes: [] + throwBoxes: [] + blockBoxes: [] + defendBoxes: [] + curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 diff --git a/Assets/Bundle/Unit/PC/Erika/AnimationData/Combo4.asset.meta b/Assets/Bundle/Unit/PC/Erika/AnimationData/Combo4.asset.meta new file mode 100644 index 00000000..d1821cc9 --- /dev/null +++ b/Assets/Bundle/Unit/PC/Erika/AnimationData/Combo4.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7570020645f11a946a824514084e6468 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Bundle/Unit/PC/Erika/AnimationData/Gun.asset b/Assets/Bundle/Unit/PC/Erika/AnimationData/Gun.asset index 115971a4..0a709ddb 100644 --- a/Assets/Bundle/Unit/PC/Erika/AnimationData/Gun.asset +++ b/Assets/Bundle/Unit/PC/Erika/AnimationData/Gun.asset @@ -10,14 +10,20 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: cab6406109041434e890f22d6455172f, type: 3} - m_Name: Gun + m_Name: Gun(Clone) m_EditorClassIdentifier: animationName: Gun animationPath: Assets/Art/Animations/Erika/Gun.anim animationEvents: [] hurtBoxes: - - type: 1 - pivot: 0 + - collider: + type: 0 + pivot: 0 + useGravity: 0 + hitBack: {x: 0, y: 0, z: 0} + multiHit: 0 + sparkPath: + multiple: 0 frames: - frame: 0 active: 1 @@ -31,3 +37,27 @@ MonoBehaviour: throwBoxes: [] blockBoxes: [] defendBoxes: [] + curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1.5 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 1.5 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 diff --git a/Assets/Bundle/Unit/PC/Erika/AnimationData/Take 001.asset b/Assets/Bundle/Unit/PC/Erika/AnimationData/Take 001.asset index 531575bc..3334e1b5 100644 --- a/Assets/Bundle/Unit/PC/Erika/AnimationData/Take 001.asset +++ b/Assets/Bundle/Unit/PC/Erika/AnimationData/Take 001.asset @@ -180,21 +180,39 @@ MonoBehaviour: m_Curve: - serializedVersion: 3 time: 0 - value: 1 - inSlope: 0 - outSlope: 0 + value: 1.1 + inSlope: -2.0588236 + outSlope: -2.0588236 tangentMode: 34 weightedMode: 0 inWeight: 0 - outWeight: 0 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 0.34 + value: 0.4 + inSlope: Infinity + outSlope: Infinity + tangentMode: 103 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.14564696 + - serializedVersion: 3 + time: 0.38 + value: 1.1 + inSlope: 7.8783245 + outSlope: Infinity + tangentMode: 97 + weightedMode: 0 + inWeight: 0.04345105 + outWeight: 0.33333334 - serializedVersion: 3 time: 1 - value: 1 + value: 1.1 inSlope: 0 outSlope: 0 tangentMode: 34 weightedMode: 0 - inWeight: 0 + inWeight: 0.33333334 outWeight: 0 m_PreInfinity: 2 m_PostInfinity: 2 diff --git a/Assets/Bundle/Unit/PC/Erika/AnimatorController/Erika_AnimatorController.controller b/Assets/Bundle/Unit/PC/Erika/AnimatorController/Erika_AnimatorController.controller index 67dd8b1b..83e2ad4b 100644 --- a/Assets/Bundle/Unit/PC/Erika/AnimatorController/Erika_AnimatorController.controller +++ b/Assets/Bundle/Unit/PC/Erika/AnimatorController/Erika_AnimatorController.controller @@ -65,7 +65,7 @@ AnimatorController: m_Controller: {fileID: 0} - m_Name: IdleStatus m_Type: 1 - m_DefaultFloat: 0 + m_DefaultFloat: 0.4 m_DefaultInt: 0 m_DefaultBool: 0 m_Controller: {fileID: 0} @@ -901,7 +901,7 @@ AnimatorStateMachine: m_ChildStateMachines: - serializedVersion: 1 m_StateMachine: {fileID: 1107282701554374512} - m_Position: {x: 612, y: -756, z: 0} + m_Position: {x: 612, y: -780, z: 0} m_AnyStateTransitions: [] m_EntryTransitions: [] m_StateMachineTransitions: {} diff --git a/Assets/Scripts/Unit/AnimationData.cs b/Assets/Scripts/Unit/AnimationData.cs index 74f5eee1..211e9acb 100644 --- a/Assets/Scripts/Unit/AnimationData.cs +++ b/Assets/Scripts/Unit/AnimationData.cs @@ -24,6 +24,8 @@ public class AnimationData : ScriptableObject // 对应的进度的播放速度,默认是1
public AnimationCurve curve;
+ public const int FPS = 30;
+
public AnimationData()
{
Keyframe frame0 = new Keyframe(0, 1);
@@ -31,6 +33,87 @@ public class AnimationData : ScriptableObject curve = new AnimationCurve(frame0, frame1);
}
+ public List<ColliderData> GetColliderBoxesByType(ColliderBox.EColliderType type)
+ {
+ switch(type)
+ {
+ case ColliderBox.EColliderType.HurtBox:
+ return hurtBoxes;
+ case ColliderBox.EColliderType.HitBox:
+ return hitBoxes;
+ case ColliderBox.EColliderType.BlockBox:
+ return blockBoxes;
+ case ColliderBox.EColliderType.ThrowBox:
+ return throwBoxes;
+ case ColliderBox.EColliderType.DefendBox:
+ return defendBoxes;
+ }
+ return null;
+ }
+
+ public ColliderInfo GetColliderInfo(ColliderBox.EColliderType type, int index, float playbackTime)
+ {
+ return GetColliderInfoByFrame(type, index, playbackTime * FPS);
+ }
+
+ public ColliderInfo GetColliderInfoByFrame(ColliderBox.EColliderType type, int index, float frame)
+ {
+ ColliderInfo info = new ColliderInfo();
+ var colliders = GetColliderBoxesByType(type);
+ if (colliders == null || colliders.Count <= index)
+ return info; //info.isValid == false
+ info = colliders[index].GetColliderInfo(frame);
+ return info;
+ }
+
+ public ColliderInfo[] GetCollidersInfo(ColliderBox.EColliderType type, float playbackTime)
+ {
+ return GetCollidersInfoByFrame(type, playbackTime * FPS);
+ }
+
+ public ColliderInfo[] GetCollidersInfoByFrame(ColliderBox.EColliderType type, float frame)
+ {
+ var colliders = GetColliderBoxesByType(type);
+ if (colliders == null || colliders.Count == 0)
+ return null;
+ ColliderInfo[] infos = new ColliderInfo[colliders.Count];
+ for(int i = 0; i < colliders.Count; ++i)
+ {
+ infos[i] = colliders[i].GetColliderInfo(frame);
+ }
+ return infos;
+ }
+
+ public ColliderInfo[] GetActiveCollidersInfo(ColliderBox.EColliderType type, float playbackTime)
+ {
+ return GetActiveCollidersInfoByFrame(type , playbackTime * FPS);
+ }
+
+ public ColliderInfo[] GetActiveCollidersInfoByFrame(ColliderBox.EColliderType type, float frame)
+ {
+ var all = GetCollidersInfoByFrame(type, frame);
+ if (all == null || all.Length == 0)
+ return null;
+ int activeCount = 0;
+ foreach(var c in all)
+ {
+ if (c.active)
+ activeCount++;
+ }
+ if (activeCount == 0)
+ return null;
+ ColliderInfo[] active = new ColliderInfo[activeCount];
+ int i = 0;
+ foreach(var c in all)
+ {
+ if(c.active)
+ {
+ active[i++] = c;
+ }
+ }
+ return active;
+ }
+
public int GetBoxesCount()
{
int hurt = hurtBoxes != null ? hurtBoxes.Count : 0;
@@ -134,6 +217,8 @@ public class AnimationData : ScriptableObject }
}
+
+
#if UNITY_EDITOR
public void OnSaveToDisk()
{
diff --git a/Assets/Scripts/Unit/Collider/ColliderData.cs b/Assets/Scripts/Unit/Collider/ColliderData.cs index ad3b7326..4c8e5bed 100644 --- a/Assets/Scripts/Unit/Collider/ColliderData.cs +++ b/Assets/Scripts/Unit/Collider/ColliderData.cs @@ -3,13 +3,22 @@ using System.Collections; using System.Collections.Generic;
using UnityEngine;
+// 用来返回某一时刻的碰撞盒几何数据
public struct ColliderInfo
{
public bool active;
+ public float frame;
public Vector3 position;
public Vector3 size;
+ public ColliderBox.EColliderType type { get { return collider.type; } }
+ public ColliderBox.Pivot pivot { get { return collider.pivot; } }
+ public ColliderBox collider;
+ public int colliderHash { get { return collider.GetHashCode(); } }
+
+ public bool isValid { get { return collider != null; } } // 没有对应的数据时为false
}
+// 某个碰撞盒的属性和帧数据,从属于animation data
[Serializable]
public class ColliderData
{
@@ -42,6 +51,8 @@ public class ColliderData {
ColliderInfo info = new ColliderInfo();
info.active = false; // default
+ info.collider = collider;
+ info.frame = frame;
int previous = 0;
int end = -1;
for (int i = 0; i < frames.Count; ++i)
diff --git a/Assets/Scripts/Unit/Component/UnitCollider.cs b/Assets/Scripts/Unit/Component/UnitCollider.cs index 46b79f26..78757706 100644 --- a/Assets/Scripts/Unit/Component/UnitCollider.cs +++ b/Assets/Scripts/Unit/Component/UnitCollider.cs @@ -3,17 +3,7 @@ using System.Collections.Generic; using UnityEngine;
[DisallowMultipleComponent]
-public class UnitCollider : MonoBehaviour
+public class UnitCollider : UnitComponent
{
- // Start is called before the first frame update
- void Start()
- {
-
- }
- // Update is called once per frame
- void Update()
- {
-
- }
}
diff --git a/Assets/Scripts/Unit/UnitTimeline.cs b/Assets/Scripts/Unit/UnitTimeline.cs index ba8e652a..478840a9 100644 --- a/Assets/Scripts/Unit/UnitTimeline.cs +++ b/Assets/Scripts/Unit/UnitTimeline.cs @@ -36,6 +36,7 @@ public partial class UnitTimeline : MonoBehaviour }
public const int kMaxEventsPerFrame = 10;
+ public const int FPS = 30; // timeline 每秒采样30次
private int m_PrevFrame = -1;
|