okay it's WORKING now

i just need to do some better dropdown stuff
This commit is contained in:
AstrlJelly 2024-02-19 19:47:41 -05:00
parent d8c1a45a2b
commit 4fd50c268b
4 changed files with 36 additions and 15 deletions

View file

@ -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:

View file

@ -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)

View file

@ -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<Animator>();
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<Animator>();
e["animator"] = string.Join(", ", animators.Select(anim => {
var obj = anim.gameObject;
// string path = "/" + obj.name;
List<string> 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 {

View file

@ -79,8 +79,7 @@ namespace HeavenStudio
public int defaultValue;
public List<string> values;
// params List<> when 😢
public Dropdown(int defaultValue, params string[] values)
public Dropdown(int defaultValue, List<string> values)
{
this.defaultValue = defaultValue;
this.values = values.ToList();