Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by supersheep · Sep 09, 2012 at 04:52 PM · scenecrashload

The best way to load scenes ingame

Hi everyone, I was just wondering, what is the best way to load scenes like levels. I dont know how unity loads scenes, but im guessing that theres more to it than just going from one scene to another. At the moment I am using this:

Application.LoadLevel("Scene1");

I seem to be running into problems with this, the game crashes between scene loads from time to time, which will ruin my game, and i can't figure out why. The games not partcuarly big, and when it crashes it freezes my whole computer, and i have to switch the power off, ctrl alt del doesnt even work. If anyone can give me any ideas that would be a massive help :) Thanks alot, Sean

Comment
Add comment · Show 2
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 PProductions · Sep 09, 2012 at 07:43 PM 0
Share

I do not have this problem. I think that Application.LoadLevel(); is the standard way of switching scenes. I presume you're running Windows 7?

avatar image amasiye313 · Sep 09, 2012 at 08:25 PM 1
Share

To the best of my knowledge that is the best way to load scenes although what you might wanna try is to try loading a scene using it's index ins$$anonymous$$d of its name so for example: ins$$anonymous$$d of

Application.LoadLevel("Scene1");

type

Application.LoadLevel(1); ***that is to say if Scene1 had a build indext of 01. Also try to build and run your game again after make this adjustment.

3 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by DaveA · Sep 09, 2012 at 09:04 PM

That's the way to do it. So now you get to debug. I would start by making your 'next' scene empty. See if you can switch to that empty scene. If so, start migrating game objects one by one from the scene that was crashing into that empty scene, noting when it starts crashing again. The last thing you added will be the culprit and then you have to find out why.

If trying to swtich to an empty scene still crashes, then it's something in the 'destroy' phase of your current scene. Start by disabling game objects one by one until it stops crashing. The last thing you disabled will be the culprit, then you have to find out why.

Comment
Add comment · Show 4 · 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 MohdGasim · Sep 09, 2012 at 09:12 PM 0
Share

great solution Dave A....i also ran into the same problem as Supersheep and will try out your solution....thanx

avatar image kristercollin · Sep 09, 2012 at 09:37 PM 0
Share

I wish I'd seen your answer before I posted $$anonymous$$e... it is quite excellent! (hadn't even considered that the destroy phase could be a culprit)

avatar image supersheep · Sep 10, 2012 at 10:25 AM 0
Share

Thanks guys, im guessing that it is something in the current scene as this scene crashes when i rotate the scene view now. something in the destroy function must be crashing it during the scene change. Ive tried using both room names and scene index, it doesn't seem to make a diffrence. Could it be a model in the scene causing the game to crash?

avatar image DaveA · Sep 12, 2012 at 01:08 AM 0
Share

It's possible, but usually it's a script. Try disabling gameobjects one by one now, see what happens.

avatar image
0

Answer by kristercollin · Sep 09, 2012 at 09:36 PM

Hey Supersheep,

I don't see anything wrong with your use of "Application.LoadLevel()". I use it all the time to load scenes according to their names, but, as Amasiye313 suggested, you can also use the indices.

Maybe you should try setting up a new project with two scenes, each scene having a gameobject inside it that will allow you to go back and forth between the scenes based on input (and nothing more), so that you can have a good comparison between both projects and it'll tell us whether there is problem with the scenes and project that you have currently (maybe they're overloaded in some way).

If you make this new project and the scene switching works, then I'd say the culprit lies elsewhere in your project, but I'll make no guesses until I hear back.

Let us know how it goes, yeah? Good luck!

Comment
Add comment · Show 1 · 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 kaliAJ · Oct 29, 2019 at 09:33 AM 0
Share

@kristercollin is " Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiveScene().buildIndex +/- 1);" the wrong way for moving to next OR previous scene? I encountered a problem, that if the current level is won,lost,tied. and if we move to main menu scene,and again if I move to the level scene then the state of the level remains the same ie: won,lost,tied etc.

avatar image
0

Answer by supersheep · Sep 10, 2012 at 01:21 PM

Possibly fixed it by removing a group of objects that all had ridgidbodies attached i'd used to mke a wall out of individual bricks. The scene it was loading from crashed during the destroy phase i think. Fingers crossed its ok now, but its one of those annoying bugs that pretends to be gone and then comes back for no reason.

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

14 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

Related Questions

Setting variable as type "Scene" 4 Answers

Scene Variable Serialization issues on crash, save etc. 1 Answer

I cant load my scene? 0 Answers

Load a scene/level when enemy is close... 1 Answer

Load 3d models with code, possible? 2 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