This question was
closed Oct 26, 2016 at 12:53 PM by
Landern for the following reason:
Duplicate of: http://answers.unity3d.com/questions/1262300/onlevelwasloaded-problem-was-found-on.html#comment-1262397
Question by
Raviraja190 · Oct 26, 2016 at 10:03 AM ·
sceneonlevelwasloadedactivex
OnLevelWasLoaded was not called
OnLevelWasLoaded Problem using UnityEngine; using System.Collections; using UnityEngine.UI; using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour { public static GameManager instance;
[HideInInspector]
public bool gameStartedFromMainMenu, gameRestartedAfterPlayerDied;
[HideInInspector]
public int Score, coinScore, lifeScore;
void Awake()
{
MakeSingleton();
}
void OnLevelWasLoaded()
{
Debug.Log("on Level Loaded");
if (SceneManager.GetActiveScene().name == "Gameplay")
{
if (gameRestartedAfterPlayerDied)
{
GamePlayController.instance.SetScore(Score);
GamePlayController.instance.SetCoinScore(coinScore);
GamePlayController.instance.SetLifeScore(lifeScore);
PlayerScoreScript.scoreCount = Score;
PlayerScoreScript.coinCount = coinScore;
PlayerScoreScript.lifeCount = lifeScore;
}
else if (gameStartedFromMainMenu)
{
PlayerScoreScript.scoreCount = 0;
PlayerScoreScript.coinCount = 0;
PlayerScoreScript.lifeCount = 2;
GamePlayController.instance.SetScore(0);
GamePlayController.instance.SetCoinScore(0);
GamePlayController.instance.SetLifeScore(2);
}
}
}
Comment