I tried to animate a message screen with TMP text so it would not pop up too suddenly, but it behaves weirdly. The code for message is this: Code (CSharp): public IEnumerator ShowMessage(float duration, VerticalAlignmentOptions vertical, HorizontalAlignmentOptions horizontal, string text) { //The object starts inactive messageBackground.gameObject.SetActive(true); //this animation changes alpha for text and bacground from zero to desired values messageBackground.gameObject.GetComponent<Animator>().Play("Show"); //set the text, obviously message.verticalAlignment = vertical; message.horizontalAlignment = horizontal; message.text = text; yield return new WaitForSeconds(duration); //Set the colors' alpha to zero, has a behaviour script with disabling the object OnStateExit() messageBackground.gameObject.GetComponent<Animator>().Play("Disappear"); } It works normally when used for the first time, but if called more than once per run, the text's alpha switches to zero after the starting animation had been finished. Telling directly to hold the alpha through transition from "show" to another animation which does nothing but this didn't help. It even seemed to work stable for some time and broke out of nowhere. How can I fix this or is there other solutions?
Upd. This behaviour is triggered by the "Disappear" animation, since removing it from the script in favor of deactivating the object removed also the problem. Also, when I created the animation, text also did not want to follow commands and become transparent, and I still don't know what exactly made it to do so.
Upd 2. Guess the entire approach with hiding an object for various messages instead of instantiating and destroying every one anew is flawed. If so, the thread is not needed anymore.