From 8c519185b0053daa23c5c5978d47baf77c1391b0 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 1 Sep 2021 19:29:48 +0800 Subject: =?UTF-8?q?*action=20tool=E7=9A=84=E5=B8=A7=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/ActionTool/Editor/ActionPreviewEditor.cs | 21 ++++---- .../Frank_RPG_Assassin_Combo02_1.asset | 2 - .../Frank_RPG_Assassin_Combo02_2.asset | 7 +-- .../Erika_AnimatorControllerCrossFade.controller | 10 ++-- Assets/Scenes/Demo/AnimationEditScene.unity | 60 ++++++++++++++++++++++ .../GameObject Profile.asset | 6 +-- .../Unit/Components/UnitAnimation/UnitAnimation.cs | 20 ++++---- .../Scripts/Unit/Components/UnitState/PCState.cs | 2 +- .../Scripts/Unit/Components/UnitState/UnitState.cs | 1 + Assets/Scripts/Unit/Controller/UnitController.cs | 2 +- Assets/Scripts/Unit/Events/EventGame_TimeScale.cs | 12 +++++ .../Unit/Events/EventGame_TimeScale.cs.meta | 11 ++++ Assets/Scripts/Unit/TimelineEventProxy.cs | 16 +++++- 13 files changed, 129 insertions(+), 41 deletions(-) create mode 100644 Assets/Scripts/Unit/Events/EventGame_TimeScale.cs create mode 100644 Assets/Scripts/Unit/Events/EventGame_TimeScale.cs.meta (limited to 'Assets') diff --git a/Assets/ActionTool/Editor/ActionPreviewEditor.cs b/Assets/ActionTool/Editor/ActionPreviewEditor.cs index 6ff60ed5..5bb2e435 100644 --- a/Assets/ActionTool/Editor/ActionPreviewEditor.cs +++ b/Assets/ActionTool/Editor/ActionPreviewEditor.cs @@ -307,7 +307,9 @@ namespace ActionTool GUI.Label(new Rect(xr, y, 510, 15), ActionManager.actionData.curAnimFrame.ToString("f2"), styles.textMiddleBold); GUI.Label(new Rect(xl + 150, y, 105, 15), "Normalized Time:", styles.textMiddle); GUI.Label(new Rect(xr + 150, y, 510, 15), ActionManager.actionData.curAnimTimeNormal.ToString("f2"), styles.textMiddleBold); - y += 15; + GUI.Label(new Rect(xl + 150 * 2, y, 105, 15), "Event Frame:", styles.textMiddle); + GUI.Label(new Rect(xr + 150 + 125, y, 510, 15), ((int)ActionManager.actionData.curAnimFrame).ToString(), styles.textMiddleBold); + y += 15; } @@ -409,7 +411,7 @@ namespace ActionTool float y = iy; float contentHeight = ActionManager.eventAndBoxCount * kFrameHeight + 40; - Rect content = new Rect(0, 0, action.totalFrame * kFrameWidth + 30, contentHeight); + Rect content = new Rect(0, 0, ((int)action.totalFrame + 1)* kFrameWidth + 30, contentHeight); float height = 300; if (position.height - kTimeLineViewYOffset > contentHeight + 15) height = contentHeight + 15; @@ -476,20 +478,20 @@ namespace ActionTool ActionData action = ActionManager.actionData; int sampleCount = (int)action.totalFrame + 1; - Rect bgRect = new Rect(kTimeLineViewXOffset, y, action.totalFrame * kFrameWidth, ActionManager.eventAndBoxCount * kFrameHeight); + Rect bgRect = new Rect(kTimeLineViewXOffset, y, sampleCount * kFrameWidth, ActionManager.eventAndBoxCount * kFrameHeight); GUI.Box(bgRect, ""); Color lineColor = new Color(0.3f, 0.3f, 0.3f); Color lineColor2 = new Color(0.5f, 0.5f, 0.5f); for (int i = 0; i < ActionManager.eventAndBoxCount + 1; i++) { - ui.DrawHorizontalLineFast(y + i * kFrameHeight, kTimeLineViewXOffset, kTimeLineViewXOffset + action.totalFrame * kFrameWidth, lineColor); + ui.DrawHorizontalLineFast(y + i * kFrameHeight, kTimeLineViewXOffset, kTimeLineViewXOffset + sampleCount * kFrameWidth, lineColor); } for(int i = 0; i <= sampleCount; ++i) { Color c = i % 5 == 0 ? lineColor2 : lineColor; float x = kTimeLineViewXOffset + i * kFrameWidth; - x = Mathf.Clamp(x, kTimeLineViewXOffset, kTimeLineViewXOffset + action.totalFrame * kFrameWidth); + //x = Mathf.Clamp(x, kTimeLineViewXOffset, kTimeLineViewXOffset + action.totalFrame * kFrameWidth); ui.DrawVerticalLineFast(x, y, y + ActionManager.eventAndBoxCount * kFrameHeight, c); } @@ -548,11 +550,6 @@ namespace ActionTool if (select) { ActionManager.OnSelectBox(box, index); - - //float length = action.totalFrame * kFrameWidth; - //ui.DrawHorizontalLineFast(y, kTimeLineViewXOffset, kTimeLineViewXOffset + length, c * 0.7f); - //ui.DrawHorizontalLineFast(y + kFrameHeight, kTimeLineViewXOffset, kTimeLineViewXOffset + length, c * 0.7f); - //ui.DrawVerticalLineFast(kTimeLineViewXOffset + length + 1, y, y + kFrameHeight, c * 0.7f); } else if(selected && !select) { @@ -608,6 +605,7 @@ namespace ActionTool if (e.button != 1 || !e.isMouse || e.type != EventType.MouseDown) return; ActionData action = ActionManager.actionData; + int sampleCount = (int)action.totalFrame + 1; float y = m_GridY + ActionManager.kMaxEventsPerFrame * kFrameHeight; Vector2 position = e.mousePosition; int boxCount = ActionManager.animationData.GetBoxesCount(); @@ -855,8 +853,9 @@ namespace ActionTool return; ActionData action = ActionManager.actionData; + int sampleCount = (int)action.totalFrame + 1; Vector2 position = Event.current.mousePosition; - Rect eventRegion = new Rect(kTimeLineViewXOffset, m_GridY, action.totalFrame * kFrameWidth, TimelineEventProxy.kMaxEventsPerFrame * kFrameHeight); + Rect eventRegion = new Rect(kTimeLineViewXOffset, m_GridY, sampleCount * kFrameWidth, TimelineEventProxy.kMaxEventsPerFrame * kFrameHeight); if (!eventRegion.Contains(position)) return; diff --git a/Assets/Bundle/Unit/PC/Erika/AnimationData/Frank_RPG_Assassin_Combo02_1.asset b/Assets/Bundle/Unit/PC/Erika/AnimationData/Frank_RPG_Assassin_Combo02_1.asset index aed0b017..df3d1d67 100644 --- a/Assets/Bundle/Unit/PC/Erika/AnimationData/Frank_RPG_Assassin_Combo02_1.asset +++ b/Assets/Bundle/Unit/PC/Erika/AnimationData/Frank_RPG_Assassin_Combo02_1.asset @@ -17,8 +17,6 @@ MonoBehaviour: animationEvents: - {fileID: 114964882930719632} - {fileID: 114533364586825402} - - {fileID: 114607369761710776} - - {fileID: 114273515162279198} hurtBoxes: [] hitBoxes: - collider: diff --git a/Assets/Bundle/Unit/PC/Erika/AnimationData/Frank_RPG_Assassin_Combo02_2.asset b/Assets/Bundle/Unit/PC/Erika/AnimationData/Frank_RPG_Assassin_Combo02_2.asset index 3f3d141a..724a553f 100644 --- a/Assets/Bundle/Unit/PC/Erika/AnimationData/Frank_RPG_Assassin_Combo02_2.asset +++ b/Assets/Bundle/Unit/PC/Erika/AnimationData/Frank_RPG_Assassin_Combo02_2.asset @@ -10,7 +10,7 @@ MonoBehaviour: m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: cab6406109041434e890f22d6455172f, type: 3} - m_Name: Frank_RPG_Assassin_Combo02_2(Clone)(Clone) + m_Name: Frank_RPG_Assassin_Combo02_2(Clone) m_EditorClassIdentifier: animationName: Frank_RPG_Assassin_Combo02_2 animationPath: Assets/Bundle/Unit/PC/Erika/AnimationClip/Frank_RPG_Assassin_Combo02_2.anim @@ -18,9 +18,6 @@ MonoBehaviour: - {fileID: 114347121473010800} - {fileID: 114766687553299966} - {fileID: 114312737581800856} - - {fileID: 114376026760716050} - - {fileID: 114330056635207858} - - {fileID: 114201303160775736} hurtBoxes: [] hitBoxes: - collider: @@ -173,7 +170,7 @@ MonoBehaviour: toggles: m_keys: 00000000 m_values: - - from: 0.57 + - from: 0.45 to: 0.83 parameters: m_keys: diff --git a/Assets/Bundle/Unit/PC/Erika/AnimatorController/Erika_AnimatorControllerCrossFade.controller b/Assets/Bundle/Unit/PC/Erika/AnimatorController/Erika_AnimatorControllerCrossFade.controller index 2cede664..17b56b71 100644 --- a/Assets/Bundle/Unit/PC/Erika/AnimatorController/Erika_AnimatorControllerCrossFade.controller +++ b/Assets/Bundle/Unit/PC/Erika/AnimatorController/Erika_AnimatorControllerCrossFade.controller @@ -421,7 +421,7 @@ AnimatorState: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Attack3 + m_Name: Attack2 m_Speed: 1 m_CycleOffset: 0 m_Transitions: [] @@ -434,7 +434,7 @@ AnimatorState: m_MirrorParameterActive: 0 m_CycleOffsetParameterActive: 0 m_TimeParameterActive: 0 - m_Motion: {fileID: 7400000, guid: 04b9fb69058af0f438a6e8a3022ff336, type: 2} + m_Motion: {fileID: 7400000, guid: 5dfb4ccf3e0777d4f84f764949fba8a6, type: 2} m_Tag: m_SpeedParameter: PlaybackSpeed0 m_MirrorParameter: @@ -685,7 +685,7 @@ AnimatorState: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: Attack2 + m_Name: Attack3 m_Speed: 1 m_CycleOffset: 0 m_Transitions: [] @@ -900,10 +900,10 @@ AnimatorStateMachine: m_Position: {x: 708, y: -552, z: 0} - serializedVersion: 1 m_State: {fileID: 1102230929257620240} - m_Position: {x: 1236, y: -456, z: 0} + m_Position: {x: 1236, y: -504, z: 0} - serializedVersion: 1 m_State: {fileID: 1102642339950476984} - m_Position: {x: 1236, y: -504, z: 0} + m_Position: {x: 1236, y: -456, z: 0} - serializedVersion: 1 m_State: {fileID: 1102101182547217892} m_Position: {x: 1236, y: -552, z: 0} diff --git a/Assets/Scenes/Demo/AnimationEditScene.unity b/Assets/Scenes/Demo/AnimationEditScene.unity index 1debe208..61639d25 100644 --- a/Assets/Scenes/Demo/AnimationEditScene.unity +++ b/Assets/Scenes/Demo/AnimationEditScene.unity @@ -1744,6 +1744,36 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 7ad9bdd473f2e5f49a7ec144e5b5c999, type: 3} +--- !u!1 &1722379007 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1722379008} + m_Layer: 0 + m_Name: Root_Particles + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1722379008 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1722379007} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 8 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2098653157 GameObject: m_ObjectHideFlags: 0 @@ -1836,3 +1866,33 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} +--- !u!1 &2111535279 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2111535280} + m_Layer: 0 + m_Name: Root_Projectiles + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2111535280 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2111535279} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 9 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scenes/Demo/AnimationEditScene_Profiles/GameObject Profile.asset b/Assets/Scenes/Demo/AnimationEditScene_Profiles/GameObject Profile.asset index 0fb7a199..06572bff 100644 --- a/Assets/Scenes/Demo/AnimationEditScene_Profiles/GameObject Profile.asset +++ b/Assets/Scenes/Demo/AnimationEditScene_Profiles/GameObject Profile.asset @@ -81,10 +81,10 @@ MonoBehaviour: value: 1 shutterAngle: overrideState: 1 - value: 270 + value: 221 sampleCount: overrideState: 1 - value: 10 + value: 9 --- !u!114 &114858105996830806 MonoBehaviour: m_ObjectHideFlags: 3 @@ -112,7 +112,7 @@ MonoBehaviour: value: {x: 0.5, y: 0.5} intensity: overrideState: 1 - value: 0.451 + value: 0.086 smoothness: overrideState: 0 value: 0.2 diff --git a/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs b/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs index 1a990252..a9c50ac3 100644 --- a/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs +++ b/Assets/Scripts/Unit/Components/UnitAnimation/UnitAnimation.cs @@ -216,22 +216,20 @@ public class AnimatorLayerInfo public void OnCrossFade(string animState, float normalizedTransitionDuration, float normalizedTimeOffset, float normalizedTransitionTime ) { - m_CurrentState = animState; - m_Animator.CrossFade(animState.ToString(), normalizedTransitionDuration, layerIndex, normalizedTimeOffset, normalizedTransitionTime); - } - - public void OnPlay(string animState, float normalizedTime) + m_CurrentState = animState; + m_Animator.CrossFade(animState.ToString(), normalizedTransitionDuration, layerIndex, normalizedTimeOffset, normalizedTransitionTime); + m_TimelineEventProxy.ResetPrevAnimationData(); + } + + public void OnPlay(string animState, float normalizedTime) { m_CurrentState = animState; - m_Animator.Play(animState, layerIndex, normalizedTime); - } + m_Animator.Play(animState, layerIndex, normalizedTime); + m_TimelineEventProxy.ResetPrevAnimationData(); + } } -// 控制动画播放、执行动作timeline(包括执行事件和碰撞盒) -// 每个layer同时只会有一个动画在播放,在执行transition时,current animation依然是 -// 这个动作,只有完全过渡完成后才会切到下一个动作 -// 当前是什么动作以ainmator的GetCurrentAnimatorStateInfo为准 [DisallowMultipleComponent] public class UnitAnimation : UnitComponent { diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState.cs b/Assets/Scripts/Unit/Components/UnitState/PCState.cs index 6bd6fa78..54a48cc2 100644 --- a/Assets/Scripts/Unit/Components/UnitState/PCState.cs +++ b/Assets/Scripts/Unit/Components/UnitState/PCState.cs @@ -208,7 +208,7 @@ public class PCState : UnitState IEnumerator Attack(SkillParam param) { - const int total = 3; + const int total = 4; int id = 0; m_Owner.pcAnimation.AnimAttack(id++); yield return null; diff --git a/Assets/Scripts/Unit/Components/UnitState/UnitState.cs b/Assets/Scripts/Unit/Components/UnitState/UnitState.cs index 4896e255..aff1e0f3 100644 --- a/Assets/Scripts/Unit/Components/UnitState/UnitState.cs +++ b/Assets/Scripts/Unit/Components/UnitState/UnitState.cs @@ -9,4 +9,5 @@ using UnityEngine; public class UnitState : UnitComponent { + } \ No newline at end of file diff --git a/Assets/Scripts/Unit/Controller/UnitController.cs b/Assets/Scripts/Unit/Controller/UnitController.cs index 9b3ef6e5..63202f29 100644 --- a/Assets/Scripts/Unit/Controller/UnitController.cs +++ b/Assets/Scripts/Unit/Controller/UnitController.cs @@ -45,7 +45,7 @@ public class UnitController : MonoBehaviour/*, Interactable*/ { get { - return transform.rotation.eulerAngles.y == 0 ? true : false; + return transform.rotation.eulerAngles.y == 0; } } diff --git a/Assets/Scripts/Unit/Events/EventGame_TimeScale.cs b/Assets/Scripts/Unit/Events/EventGame_TimeScale.cs new file mode 100644 index 00000000..df393a6b --- /dev/null +++ b/Assets/Scripts/Unit/Events/EventGame_TimeScale.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EventGame_TimeScale : AnimationEventBase +{ + public override TimelineEventProxy.EEventType type { get { return TimelineEventProxy.EEventType.EventGame_TimeScale; } } + public override string shortName { get { return "T"; } } + + public AnimationCurve curve; + +} \ No newline at end of file diff --git a/Assets/Scripts/Unit/Events/EventGame_TimeScale.cs.meta b/Assets/Scripts/Unit/Events/EventGame_TimeScale.cs.meta new file mode 100644 index 00000000..8b5d5745 --- /dev/null +++ b/Assets/Scripts/Unit/Events/EventGame_TimeScale.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 227b9bc615c7c8044be9c4547dee5fcf +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Unit/TimelineEventProxy.cs b/Assets/Scripts/Unit/TimelineEventProxy.cs index e56f590a..de067455 100644 --- a/Assets/Scripts/Unit/TimelineEventProxy.cs +++ b/Assets/Scripts/Unit/TimelineEventProxy.cs @@ -16,7 +16,11 @@ public partial class TimelineEventProxy get { if (m_Root_Particles == null) - m_Root_Particles = new GameObject("Root_Particles"); + { + m_Root_Particles = GameObject.Find("Root_Particles"); + if(m_Root_Particles == null) + m_Root_Particles = new GameObject("Root_Particles"); + } return m_Root_Particles; } } @@ -25,6 +29,7 @@ public partial class TimelineEventProxy { get { + m_Root_Projectiles = GameObject.Find("Root_Projectiles"); if (m_Root_Projectiles == null) m_Root_Projectiles = new GameObject("Root_Projectiles"); return m_Root_Projectiles; @@ -41,7 +46,9 @@ public partial class TimelineEventProxy #endif public enum EEventType - { + { + EventGame_TimeScale, // 缩放时间 + EventCamera_Zoom, // 相机聚焦 EventCamera_Shake, // 相机晃动 EventCamera_Blur, // 相机模糊 @@ -91,6 +98,11 @@ public partial class TimelineEventProxy return type; } + public void ResetPrevAnimationData() + { + m_PrevAnimationData = null; + } + public void ExecuteAnimationEvents(AnimationData animData, float animFrame) { if (animData == null) -- cgit v1.1-26-g67d0