I am developing a UI drop down list in Unity3D. How do I make the animator stay on animation state rather than resetting to idle on re enable of GameObject?
I have listed below the issue in points
- press UI button that plays drop down animation clip
- press same UI button again and fold up animation clip is played
- press UI button and drop down plays again
- set GameObject active to false when the drop down clip has been played
- Set GameObject to true whilst the list is dropped down
- press button to try and fold up but doesn't work like before GameObject was set to false.
I have attached the class used OnClick of the UI button below. I want the same behaviour that was apparent before the GameObject was set to false. The link is to a video that shows the issue.
https://gfycat.com/gifs/detail/skinnynegativechuckwallausing System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CustomDropDown : MonoBehaviour {
public GameObject SubMenu;
[HideInInspector]
public int State = 0;
Animator AniPlayer;
public void BtnDropDown()
{
if (AniPlayer.GetInteger("MenuState") == 0)
{
AniPlayer.SetInteger("MenuState", 1);
}
else if (AniPlayer.GetInteger("MenuState") == 1)
{
AniPlayer.SetInteger("MenuState", 0);
}
}
// Use this for initialization
void Start() {
AniPlayer = this.GetComponent<Animator>();
}
}