I have custom menu item with a script attached that triggers an animation via
SetTrigger. This happens in the
OnEnable() function.
Now the problem is, that OnEnable gets called twice and with it, so does the OnDisable, causing the animator to reset the parameter since it got disabled and enabled once again.
The menu item has appear type set
During gameplay, so this is probably the cause for this issue.
This is the relevant code from the script attached to the root object of the UI Element.
private void OnEnable()
{
var a = AC.GlobalVariables.GetAllVars().Find(x => x.label == globalIntVar_State);
Debug.Log(animator);
if (a != null && a.IntegerValue == 2)
{
Debug.Log(a.IntegerValue);
button.SetActive(true);
GetComponent<Animator>().SetTrigger("new location unlocked");
animator.SetTrigger("new location unlocked");
Debug.Log(animator.enabled);
a.IntegerValue = 1;
}
}
Off: I'd like to point out that this forum has serious issues regarding the search feature and editing posts(bold does not work for example).
Comments
@ChrisIceBox 1 or 2 weeks ago the search feature changed in a way that it now finds more literal results, like seen in this screenshot: http://prntscr.com/lmdp5o .
I hardly find any usable results in comparison to before. The display of the results changed as well.
I will use the from you suggested custom events, they seem perfect for this case, thanks!
"site:https://adventurecreator.org/forum/ search"