So i have a animated UI obj (A button) that plays the animation (is switching sprites, between sprite1 and sprite2) after a certain condition, after the button is pressed the sprite of the button changes to sprite3 but when I’m Setting active the button to false (SetActive(false)) and reanable to SetActive(true) with code the animation start’s playing although I expect the button to stay the sprite3. How to dont let the Animation play after SetActive(true)???
My Code:
using UnityEngine;
using UnityEngine.UI;
public class ChangeClaim : MonoBehaviour{[SerializeField] private Animator Switch;[SerializeField] private Image ClaimBut;[SerializeField] private Sprite ButSprite;
// Start is called before the first frame updateprivate void Update(){
if (PlayerPrefs.GetInt("Compl1") == 1){ClaimBut.sprite = ButSprite;}
if (PlayerPrefs.GetInt("Complete1") == 1){playSwitch();}
}
public void playSwitch(){if (PlayerPrefs.GetInt("Compl1") == 0){Switch.SetTrigger("Start");}}
public void StopSwitch(){Switch.SetTrigger("Stop");PlayerPrefs.SetInt("Compl1", 1);}
}
Chris der Hov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.