From 5669babc0fba32fa781608c3bc3a64d4f6a3ccc8 Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Thu, 9 Mar 2023 13:35:49 +0800 Subject: [PATCH] Fixed animator components in scripts not being retrievable. Also added script for testing animations --- Assets/Scenes/anim.shade | 29 +++++++++++++++++++--- Assets/Scripts/AnimTest.cs | 41 +++++++++++++++++++++++++++++++ Assets/Scripts/AnimTest.cs.shmeta | 3 +++ SHADE_Managed/src/Engine/ECS.cxx | 5 +++- 4 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 Assets/Scripts/AnimTest.cs create mode 100644 Assets/Scripts/AnimTest.cs.shmeta diff --git a/Assets/Scenes/anim.shade b/Assets/Scenes/anim.shade index aa42fc11..c553b17d 100644 --- a/Assets/Scenes/anim.shade +++ b/Assets/Scenes/anim.shade @@ -10,6 +10,7 @@ Color: {x: 1, y: 1, z: 1, w: 1} Layer: 4294967295 Strength: 1 + Casting Shadows: false IsActive: true Scripts: ~ - EID: 2 @@ -23,11 +24,33 @@ Scale: {x: 1, y: 1, z: 1} IsActive: true Renderable Component: - Mesh: 148542784 - Material: 121518381 + Mesh: 149697411 + Material: 128805346 IsActive: true Animator Component: Rig: 76586906 - Clip: 76586906 + AnimationController: 0 + IsActive: true + Scripts: + - Type: SHADE.Test.AnimTest + Enabled: true + idleClip: 227450439 + runClip: 229125027 + pickUpClip: 219605278 +- EID: 1 + Name: Default + IsActive: true + NumberOfChildren: 0 + Components: + Camera Component: + Position: {x: 0, y: 0.5, z: 0.699999988} + Pitch: 0 + Yaw: 0 + Roll: 0 + Width: 1920 + Near: 0.00999999978 + Far: 10000 + Perspective: true + FOV: 90 IsActive: true Scripts: ~ \ No newline at end of file diff --git a/Assets/Scripts/AnimTest.cs b/Assets/Scripts/AnimTest.cs new file mode 100644 index 00000000..376fb372 --- /dev/null +++ b/Assets/Scripts/AnimTest.cs @@ -0,0 +1,41 @@ +namespace SHADE.Test +{ + public class AnimTest : Script + { + #region Serialized Fields + [SerializeField] + private AnimationClipAsset idleClip; + [SerializeField] + private AnimationClipAsset runClip; + [SerializeField] + private AnimationClipAsset pickUpClip; + #endregion + + #region Components + public Animator Animator { get; private set; } + #endregion + + #region Lifecycle Functions + protected override void awake() + { + Animator = GetComponent(); + } + + protected override void update() + { + if (Input.GetKeyUp(Input.KeyCode.Alpha1)) + { + Animator.Play(idleClip); + } + else if (Input.GetKeyUp(Input.KeyCode.Alpha2)) + { + Animator.Play(runClip); + } + else if (Input.GetKeyUp(Input.KeyCode.Alpha3)) + { + Animator.Play(pickUpClip); + } + } + #endregion + } +} \ No newline at end of file diff --git a/Assets/Scripts/AnimTest.cs.shmeta b/Assets/Scripts/AnimTest.cs.shmeta new file mode 100644 index 00000000..45df5a57 --- /dev/null +++ b/Assets/Scripts/AnimTest.cs.shmeta @@ -0,0 +1,3 @@ +Name: AnimTest +ID: 165676130 +Type: 9 diff --git a/SHADE_Managed/src/Engine/ECS.cxx b/SHADE_Managed/src/Engine/ECS.cxx index 5b73b64e..c79175bf 100644 --- a/SHADE_Managed/src/Engine/ECS.cxx +++ b/SHADE_Managed/src/Engine/ECS.cxx @@ -32,6 +32,8 @@ of DigiPen Institute of Technology is prohibited. #include "UI\SHUIComponent.h" #include "UI\SHSliderComponent.h" #include "UI\SHCanvasComponent.h" +#include "Animation\SHAnimatorComponent.h" +#include "Graphics\MiddleEnd\TrajectoryRendering\SHTrajectoryRenderableComponent.h" // Project Headers #include "Utility/Convert.hxx" #include "Utility/Debug.hxx" @@ -47,7 +49,7 @@ of DigiPen Institute of Technology is prohibited. #include "Components\Canvas.hxx" #include "Components\Slider.hxx" #include "Components\TrajectoryRenderable.hxx" -#include "Graphics\MiddleEnd\TrajectoryRendering\SHTrajectoryRenderableComponent.h" +#include "Components\Animator.hxx" @@ -338,6 +340,7 @@ namespace SHADE componentMap.Add(createComponentSet()); componentMap.Add(createComponentSet()); componentMap.Add(createComponentSet()); + componentMap.Add(createComponentSet()); } /*---------------------------------------------------------------------------------*/