Hey!
so i want to do this ui animation where every slot pops up with a small delay. something like this: https://media.giphy.com/media/xT1XGB4HHqRP8aNtlu/giphy.gif (Iam talking about the the appearance of the building slots (Landing Craft, Radar, Armory…))
what i did so far is, creating the pop up animation called “slot_open” with a event that calls the function StartNextTabAnimation() from the ActivateNextAnimation.cs at frame 60of100,and having this script to gather all the slots inside a canvas:
using UnityEngine;
using System.Collections;
using System.Linq;
public class AnimateSlots : MonoBehaviour {
public GameObject[] m_Slots;
private void Update ()
{
GameObject[] m_TargetsGO = GameObject.FindGameObjectsWithTag("Slots").OrderBy( go => go.name ).ToArray();
m_Slots = new GameObject[m_TargetsGO.Length];
for(int i = 0; i < m_TargetsGO.Length; ++i)
{
m_Slots <em>= m_TargetsGO*;*</em>
* }*
* }*
}
so my hierarchy is this:
-Canvas
–BuidMenu (where the AnimateSlots.cs is on)
—Slot1 (Button with Animator&ActivateNextAnimation.cs)
—Slot2 (Button with Animator&ActivateNextAnimation.cs)
—Slot3 (Button with Animator&ActivateNextAnimation.cs)
—Slot4 (Button with Animator&ActivateNextAnimation.cs)
so with the script above, i get a list with all slots inside the BuildMenu (cause you dont know how many slots will be in there). and on the Slots1-4 there is a Animator and this Script:
using UnityEngine;
using System.Collections;
public class ActivateNextAnimation : MonoBehaviour
{
* public Animator nextTab;*
* public void StartNextTabAnimation()*
* {*
* if (nextTab != null) nextTab.Play(“slot_open”);
_ }_
_}*_
so my problem now is, that i have to place all the nextTabs by hand in the Slots1-4
So at slot1 i have to drag in the animator of slot2 and so on which isnt pretty much dynamic.
by the way: the very fist animation for Slot1 gets triggered by a Button which is not inside the BuildMenu using the Button component OnClickEvent (Animator.Play).