- Home /
Unable to show button after an event
I am having a bit of trouble trying to make a button appear after a specific timed event. The button is a skip button to allow a user to skip the animation play after a win cycle to continue to the next level. Basically, the button stops the animations and forces the game to end the level with all the points collected. When clicking on the button, the win overlay popup will show and display the final score. This button is to stop the " burn last moves " event and convert them into integers in the score in my other script. I am only interested in getting the button to appear after the target has been reached.
The following is the code that I have created to show when the button should occur during an event in a mobile game:
using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Linq; using Berry.Utils; using UnityEngine.UI;
public class SkipLevelBtnScript : MonoBehaviour {
public static SkipLevelBtnScript main;
public GameObject SkipLevelBtn;
public int score = 0;
public bool reachedTheTarget = false;
IEnumerator SkipSession(System.Func<bool> success, System.Func<bool> failed = null) {
SkipLevelBtn.SetActive (false);
if (score >= LevelProfile.main.firstStarScore && success.Invoke() && (failed == null || !failed.Invoke())){
reachedTheTarget = true;
SkipLevelBtn.gameObject.SetActive (true);
}
yield return new WaitForSeconds(0.33f);
}
}
Your answer
Follow this Question
Related Questions
Buttons don't work after Unity 2017 update 0 Answers
UI Button not calling function properly? 2 Answers