Question by
unity_gR0Ni-1ZCuVaLw · Jul 06, 2021 at 09:52 PM ·
c#animationanimator
Animator transition not working on parameter
i have an image with 2 animations, one of them turns down the alpha, the other does the opposite.
there is a transition from entry to the second animation, which has a condition that parameter "open" is true. but in my script when i press the button, the script turns on open, but the transition doesnt work.. there are 2 scripts, they both work together.
first script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class sceneTransfer : MonoBehaviour
{
// bi is build index for next scene
public Button button;
public int bi;
public transitionControl sc;
void Start()
{
button.onClick.AddListener(trans);
}
// Update is called once per frame
void trans()
{
Debug.Log("Pressed");
sc.opening(bi);
}
}
and the second script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class transitionControl : MonoBehaviour
{
public Animator anim;
public float delay = 1f;
int b;
public void opening(int buildIndex)
{
Debug.Log("Triggerred");
b = buildIndex;
anim.SetTrigger("open");
Invoke("loads", delay);
}
void loads()
{
Debug.Log("Wait over!");
SceneManager.LoadScene(b);
}
}
while the game was running, i checked in animator and the open parameter was true, but the transition wasnt working. and the debug.logs in the scripts all work.
my OS: Windows 10
what this game is for: Android
Unity Version: 2020.3.13f1
Comment