Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Raviraja190 · Oct 25, 2016 at 05:46 PM · load sceneawakeonlevelwasloaded

OnLevelWasLoaded Problem was Found On

 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);
             }
         }
     }
 
     void InitializeVariables()
     {
         if (PlayerPrefs.HasKey("Game Initialized"))
         {
             GamePreferences.SetEasyDifficultyState(0);
             GamePreferences.SetEasyDifficultyCoinScore(0);
             GamePreferences.SetEasyDifficultyHighScore(0);
 
             GamePreferences.SetMediumDifficultyState(0);
             GamePreferences.SetMediumDifficultyCoinScore(0);
             GamePreferences.SetMediumDifficultyHighScore(0);
 
             GamePreferences.SetHardDifficultyState(0);
             GamePreferences.SetHardDifficultyCoinScore(0);
             GamePreferences.SetHardDifficultyHighScore(0);
 
             GamePreferences.SetMusicState(0);
             PlayerPrefs.SetInt("Game Initializes", 123);
         }
     }
   
     void MakeSingleton()
     {
         if (instance != null)
         {
             Destroy(gameObject);
         }
         else
         {
             instance = this;
             DontDestroyOnLoad(gameObject);
         }
     }
     public void CheckGameStatus(int Score, int CoinScore, int lifeScore)
     {
         if (lifeScore < 0)
         {
 
             if (GamePreferences.GetEasyDifficultyState() == 1)
             {
                 int highScore = GamePreferences.GetEasyDifficultyHighScore();
                 int coinHighScore = GamePreferences.GetEasyDifficultyCoinScore();
 
                 if (highScore < Score)
                     GamePreferences.SetEasyDifficultyHighScore(Score);
                 if (coinHighScore < coinScore)
                     GamePreferences.SetEasyDifficultyCoinScore(CoinScore);
             }
 
             if (GamePreferences.GetMediumDifficultyState() == 1)
             {
                 int highScore = GamePreferences.GetMediumDifficultyHighScore();
                 int coinHighScore = GamePreferences.GetMediumDifficultyCoinScore();
 
                 if (highScore < Score)
                     GamePreferences.SetMediumDifficultyHighScore(Score);
                 if (coinHighScore < coinScore)
                     GamePreferences.SetMediumDifficultyCoinScore(CoinScore);
             }
 
             if (GamePreferences.GetHardDifficultyState() == 1)
             {
                 int highScore = GamePreferences.GetHardDifficultyHighScore();
                 int coinHighScore = GamePreferences.GetHardDifficultyCoinScore();
 
                 if (highScore < Score)
                     GamePreferences.SetHardDifficultyHighScore(Score);
                 if (coinHighScore < coinScore)
                     GamePreferences.SetHardDifficultyCoinScore(CoinScore);
             }
 
             gameStartedFromMainMenu = false;
 
             GamePlayController.instance.GameOverShowPanel(Score, CoinScore);
         }
         else
         {
             this.Score = Score;
             this.coinScore = CoinScore;
             this.lifeScore = lifeScore;
 
             gameStartedFromMainMenu = false;
             gameRestartedAfterPlayerDied = true;
 
             GamePlayController.instance.PlayerDiedRestartTheGame();
         }
     }
 }


Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Landern · Oct 25, 2016 at 05:57 PM 0
Share

What is the problem? What is the error? Was this suppose to be a delegate to be used with Scene$$anonymous$$anager.sceneLoaded? Explain please.

avatar image Raviraja190 Landern · Oct 25, 2016 at 05:59 PM 0
Share

OnLevelWasLoaded found on game manager warning comes on. and the level loading problem The void onlevelwasloaded is not reading

avatar image hexagonius Raviraja190 · Oct 25, 2016 at 08:34 PM 0
Share

I don't understand what you're saying

Show more comments
avatar image Raviraja190 Landern · Oct 25, 2016 at 06:41 PM 0
Share

DontDestroyOnLoad is appearing after level reload

avatar image Raviraja190 Landern · Oct 26, 2016 at 10:16 AM 0
Share

From Line 20-50 void (OnLevelWasLoaded) is not working

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by hexagonius · Oct 26, 2016 at 07:00 PM

Ah, ok... looking up a thread, it seems, that it's deprecated and taken over by the new SceneManager class.

https://community.unity.com/t5/5-4-Beta/OnLevelWasLoaded-deprecation/td-p/2557694

There is a sceneLoaded callback described in the docs:
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager-sceneLoaded.html

The docs are a bit sh*** about that right now, but this is how it works:

 void Awake () {
         SceneManager.sceneLoaded += LoadScene;
     }
 
     void LoadScene(Scene scene, LoadSceneMode mode){
         Debug.Log ("Scene is loaded");
     }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Raviraja190 · Oct 30, 2016 at 05:35 PM

I want Rectangle 2d to rotate when in air to the gravity and to be stopped at same position when colliding with the Object or any sprite.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

76 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Since OnLevelWasLoaded is deprecated (in 5.4.0b15) What should be use instead? 3 Answers

Destroy object when a new scene loads 0 Answers

Load Scene with 2 GameObjects OnTriggerEnter 1 Answer

Addressable localload,sprite get pink when apk update first open 0 Answers

Execution order 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges