From 4fd50c268b102a2f7209064c1ec9c0e199c6e068 Mon Sep 17 00:00:00 2001 From: AstrlJelly Date: Mon, 19 Feb 2024 19:47:41 -0500 Subject: [PATCH] okay it's WORKING now i just need to do some better dropdown stuff --- Assets/Scenes/Editor.unity | 8 ++++---- Assets/Scripts/GameManager.cs | 9 ++++++--- Assets/Scripts/Minigames.cs | 31 ++++++++++++++++++++++++------ Assets/Scripts/Util/EntityTypes.cs | 3 +-- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index c7ac4df97..8cb509df8 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -24624,7 +24624,7 @@ MonoBehaviour: m_HandleRect: {fileID: 1589389271} m_Direction: 2 m_Value: 1 - m_Size: 1 + m_Size: 0.9971497 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -30367,7 +30367,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 0, y: 121.30615} + m_AnchoredPosition: {x: 0, y: 121.10164} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!222 &1154875945 @@ -39827,8 +39827,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1220118245} m_HandleRect: {fileID: 1220118244} m_Direction: 2 - m_Value: 1.0000008 - m_Size: 0.78099126 + m_Value: 1.0000005 + m_Size: 0.60513115 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 3e42293f5..876e19324 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -40,7 +40,6 @@ namespace HeavenStudio public string currentGame { get; private set; } public GameObject minigameObj { get; private set; } public Minigame minigame { get; private set; } - public Animator[] minigameAnimators { get; set; } public RiqEntity lastSection { get; private set; } public RiqEntity currentSection { get; private set; } @@ -631,9 +630,13 @@ namespace HeavenStudio } } - public void PlayAnimationArbitrary(int animator, int animation, float scale) + public void PlayAnimationArbitrary(string animator, string animation, float scale) { - + // if possible (efficient enough) id like to find the object recursively, but for now this works + Transform animTrans = minigameObj.transform.Find(animator); + if (animTrans != null && animTrans.TryGetComponent(out Animator anim)) { + anim.DoScaledAnimationAsync(animation, scale); + } } public void ToggleInputs(bool inputs) diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index e70520018..b0356f201 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -1166,14 +1166,33 @@ namespace HeavenStudio var gm = GameManager.instance; Minigame game = gm.GetGameInfo(gm.currentGame); if (game != null) { - gm.minigameAnimators = gm.minigameObj.transform.GetComponentsInChildren(); - e["animators"].values = gm.minigameAnimators.Select(x => x.name).ToList(); - e["animations"] = gm.minigameAnimators[0].runtimeAnimatorController.animationClips.Select(x => x.name).ToList(); + var animators = gm.minigameObj.transform.GetComponentsInChildren(); + e["animator"] = string.Join(", ", animators.Select(anim => { + var obj = anim.gameObject; + // string path = "/" + obj.name; + List path = new() { obj.name }; + while (obj.transform.parent != null && obj.transform.parent.name != game.name) + { + obj = obj.transform.parent.gameObject; + path.Add(obj.name); + } + return string.Join('/', path); + })); } return game?.displayName ?? "No Game"; - }), "Button", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"), - new Param("animators", new EntityTypes.Dropdown(0, "N/A"), "Animator", "Specify which animator in the scene to play an animation on. (i.e \"Plalin\" or \"Game/Paddlers/Player\")"), - new Param("animations", new EntityTypes.Dropdown(0, "N/A"), "Animation", "Specify the name of the animation to play."), + }), "Get Animators", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"), + new Param("animator", "", "Animator", "Specify which animator in the scene to play an animation on."), + new Param("getAnimations", new EntityTypes.Button("N/A", e => { + var gm = GameManager.instance; + Minigame game = gm.GetGameInfo(gm.currentGame); + var animObj = gm.minigameObj.transform.Find((string)e["animator"]); + Animator animator = null; + if (animObj != null && animObj.TryGetComponent(out animator)) { + e["animations"] = string.Join(", ", animator.runtimeAnimatorController.animationClips.Select(x => x.name)); + } + return animator != null ? animator.name : "N/A"; + }), "Get Animations", "Get all the animators in the current minigame scene. (Make sure to have the minigame you want loaded!)"), + new Param("animations", "", "Animation", "Specify the name of the animation to play."), new Param("scale", new EntityTypes.Float(0, 5, 0.5f), "Animation Scale", "The time scale of the animation. Higher values are faster."), }, delegate { diff --git a/Assets/Scripts/Util/EntityTypes.cs b/Assets/Scripts/Util/EntityTypes.cs index 830681d88..c7f1a285b 100644 --- a/Assets/Scripts/Util/EntityTypes.cs +++ b/Assets/Scripts/Util/EntityTypes.cs @@ -79,8 +79,7 @@ namespace HeavenStudio public int defaultValue; public List values; - // params List<> when 😢 - public Dropdown(int defaultValue, params string[] values) + public Dropdown(int defaultValue, List values) { this.defaultValue = defaultValue; this.values = values.ToList();