using ExaGames.Common.TimeBasedLifeSystem;
using UnityEngine;
public class Try : MonoBehaviour {
public LivesManager LivesManager;
public DemoResultDisplayController ResultDisplay;
#region Button Event Handlers
public void OnButtonConsumePressed() {
if(LivesManager.ConsumeLife()) {
Debug.Log(“A life was consumed and the player can continue!”);
ResultDisplay.Show(true);
} else {
Debug.Log(“Not enough lives to play!”);
ResultDisplay.Show(false);
}
}
#endregion
}
Well there is not much to tell from that code except that you will find your problem in LivesManager.ConsumeLife().
Add a lot of logs there to figure out why it always returns false;
When it’s false then the else works but if true then nothing no debug I tried placing a restart script but that won’t work either
How do you know it is true? No where in your code are you printing the result of the ConsumeLife method. This seems to me like an assumption you are making.
When you are not sure, add more debug log statements and split code up.
Replace
if(LivesManager.ConsumeLife()) {
with
bool hasLives = LivesManager.ConsumeLife();
Debug.Log("hasLives? " + hasLives);
if (hasLives){
I suspect that either ConsumeLife() is always false, or that the OnButtonConsumePressed method is not being called when ConsumeLife() is true.
1 Like