• 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 Aldo Alain · Nov 02, 2015 at 04:28 PM · application.loadlevel

Application.LoadLevel problem

Hello to all, i have read all the documentation, but nothing. So if anyone can give me a hint! ?

I have a Main menu that Calls an another Scene and that Scene calls another Scene, everything works just fine the first time.

But when I load the second scene for a second time it doesnt load at all, it hangs. I mean, the second cicle dont work. This is the exact problem:

MainMenu calls First Dialog, this one autojump at the end to the first level... in that first level there is a buttom to go to MainMenu, I works well and go to the MainMenu but when it calls AGAIN the First dialog, it hangs and doesnt show a thing...

Im using aplication.loadlevel plain and simple.

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 OncaLupe · Nov 02, 2015 at 04:45 PM 0
Share

Please post the code here. Without seeing how you've set it up, we can't really help you.

avatar image Statement · Nov 02, 2015 at 05:07 PM 0
Share

The only common thing people overlook with LoadLevel is that the level has to exist in Build Settings for the level to load. But if you were able to load it once before (not starting in it, actually loading it) then obviously it's not the issue here.

Other than that, perhaps you're doing something like setting Time.timeScale to zero and forget to set it back to 1. Or you have some static variable dirty from a previous run, perhaps causing a infinite loop, hanging the editor etc. Or you're using DontDestroyOnLoad for some objects which cause problems when entering a level that has the same object that you meant to not destroy on load. It runs into it's twin and game gets confused.

If it hangs, try attaching the debugger and breaking execution to see where it spins.

avatar image Aldo Alain · Nov 02, 2015 at 05:58 PM 0
Share

Thanks to both! Statement: Indeed, the scene its called once and works well, but the second call its the problem, it doesnt load. Its a plugin I bought.

$$anonymous$$y plan its to debugg, find issue (i think on variables now), and make them publiic (if it doesnt crash anything) or reinitialize in the code, everytime.

I will start the debug now!

Thanks guys,

Arcanebits

avatar image Statement Aldo Alain · Nov 02, 2015 at 07:14 PM 0
Share

If it's using threads, that could also be something to have a look at. In my experience, threads can often lock up the engine/editor if they are not handled correctly.

avatar image Arcanebits · Nov 02, 2015 at 07:20 PM 0
Share

Hello, im using my original Profile, Aldo Alain its one I created because of reasons...

I did go and replaced every private var to public var, that must clean every variable when i load another scene. Didnt work.

I looked every timescale related and found that they are perfectly initialized on the start of the program. So this wasnt it neither.

DontDestroyOnLoad is not used in any part of the code, so.. This wasnt neither.

I tried monodebug but it is really tricky and it didnt work out for me.

At this point im beggining the (maybe i wont need that plugin that cost me 99bucks) frustration level...

Starting to seek workarounds.... Its there a way to clean everything from RA$$anonymous$$, like restarting the app again but only once?

Aldo "Arcanebits" Alain

avatar image Statement Arcanebits · Nov 02, 2015 at 08:37 PM 0
Share

I did go and replaced every private var to public var, that must clean every variable when i load another scene. Didnt work.

It shouldn't work to begin with, and exposing visibility is not a good option. It can actually introduce subtle bugs because now the previously private variables can no longer have an expected initial value. If scripts had a int i; or something you made public, and an editor script does something temporarily with i, that change will now have been recorded into your scene and when the script runs, i won't start at 0, it will start at whatever the script set it to. No. No. No. This is opening up a can of worms :)

I tried monodebug but it is really tricky and it didnt work out for me.

Debugging should be your main route of attack. If it was tricky, figure out how to make it untricky. Are you inexperienced, or what is the tricky part of it?

At this point im beggining the (maybe i wont need that plugin that cost me 99bucks) frustration level...

Well, contact the author and explain what happens. Before you do that, you should be polite and verify that it works if you remove/disable that plugin. Even politer, you should try and figure out what integration causes the issue (like, it happens if I use your plugin and dont have a camera in the scene, the game will hang). You're much more likely to get a faster response + fix from the author of the plugin if they have as detailed and simple information as possible.

Starting to seek workarounds.... Its there a way to clean everything from RA$$anonymous$$, like restarting the app again but only once?

No, not really. It'd probably involve unloading the app domain but you'd terminate your own thread of execution as well I think. Besides, I am sure Unity would just roll over and die. This is just my projection of what I think will happen. You're welcome to try, but I would be surprised if you managed to do it. Also you'd leave Unity in a pretty confused state if all its references suddenly were invalid. I wouldn't make this a goal if I were in your shoes.

If I were you: I'd go back to the debugger. If it's really tricky, make it untricky. What is tricky? You're so abstract man :) Once you figured out what is happening with the debugger, you should have a clear idea if it's due to your code or the code in the plugin. You should also know which part of the plugin hangs, and under which conditions. It would be the sensible route to take.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

34 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

Related Questions

Question regarding OnTriggerEnter and Application.LoadLevel 1 Answer

Application.loadlevel adding double scripts to objects 0 Answers

Standalone build fails Application.LoadLevel() and Freezes 1 Answer

How to change level after my game over screen appears? C# 1 Answer

Windows Phone 8.1 crash when loading first scene 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges