Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
11
Question by timrox99 · Oct 03, 2014 at 10:37 AM · sceneresolutioncheck

How to restart scene properly

Hey. So I know that I could simply restart my scene by getting the name of the scene and putting it in some script, but I want to use a script that will work on multiple scenes that checks the current scene and restarts it without requiring a scene name. If someone can provide a simple script that performs this action, I will be more than happy. Cheers.

Comment
Add comment
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

3 Replies

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

Answer by Josh Naylor · Oct 03, 2014 at 10:38 AM

Use

 Application.LoadLevel(Application.loadedLevel);

Comment
Add comment · Show 9 · 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 timrox99 · Oct 03, 2014 at 11:41 AM 0
Share

Thanks heaps

avatar image logicalOctopus · Feb 14, 2016 at 11:47 PM 0
Share

deprecated code!

avatar image zack_wilson · May 06, 2016 at 06:52 PM 0
Share

IT GOT RID OF $$anonymous$$Y LIGHT

avatar image MakerDavid zack_wilson · May 06, 2016 at 06:56 PM 5
Share

Hi Zack. This is not a problem. The light will be there when you make a build and run it. To fix it in the editor you can however do this: To fix it in the Editor, go to Window -> Lighting -> Lightmap Tab -> Disable Continuous Baking -> Press Build to bake the lighting once manually.

avatar image zack_wilson MakerDavid · May 06, 2016 at 07:08 PM 0
Share

oh my gosh i love you so much dude

Show more comments
Show more comments
avatar image RavenHardt · Dec 28, 2017 at 10:07 PM 0
Share

Hello, I need help @$$anonymous$$aker$$anonymous$$ I cant find how to turn off continuous baking in the settings (I'm Using Unity 2017.3)

avatar image anjandeveloper · Mar 27, 2021 at 08:27 AM 1
Share

It is deprecated now. Use SceneManager instead.

avatar image
43

Answer by mikiqex · Dec 21, 2015 at 01:11 PM

UnityEngine.Application.LoadLevel is obsolete, use SceneManager.LoadScene:

 using UnityEngine.SceneManagement;
 ...
 SceneManager.LoadScene("Scene_Name");
Comment
Add comment · Show 7 · 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 Caleb_1701 · Dec 23, 2015 at 07:56 PM 0
Share

It's not working on my computer. Is there something wrong with this code? By the way, Hurts is a function that is called when the enemy sends a message to the player (I'm pretty sure that the problem isn't in there, because I already used a Send$$anonymous$$essage for something else in the game and it works fine)

  using UnityEngine;
 using System.Collections;
 using UnityEngine.Scene$$anonymous$$anagement;
 //code and stuff
 void Hurts (int amount) {
         health -= amount;
         if (health <= 0) {
             Scene$$anonymous$$anager.LoadScene("dungeon 1");
         }
     }



It says "The type or namespace name 'Scene$$anonymous$$anagement' does not exist in the namespace 'UnityEngine'. Are you missing an assembly reference?"

avatar image mikiqex Caleb_1701 · Dec 24, 2015 at 01:41 PM 0
Share

Do you use the latest Unity? If not, it's possible Scene$$anonymous$$anagement isn't present in yours version yet.

avatar image Triggerly Caleb_1701 · Jan 02, 2020 at 12:37 AM 1
Share

Sorry this is 2020 lol but is your scene in build settings? If not drag your scene into the scenes area

avatar image kevinrocks_786 · Dec 23, 2015 at 08:48 PM 11
Share

Actually, to restart the CURRENT scene, you would do:

 Scene$$anonymous$$anager.LoadScene(GetActiveScene().name);
avatar image Orolo kevinrocks_786 · Dec 24, 2015 at 02:53 AM 5
Share

Thanks. You forgot a Scene$$anonymous$$anager. though.

 Scene$$anonymous$$anager.LoadScene (Scene$$anonymous$$anager.GetActiveScene ().name);
avatar image luckynamal Orolo · Apr 21, 2016 at 09:24 AM 6
Share

using UnityEngine.Scene$$anonymous$$anagement;

Scene$$anonymous$$anager.LoadScene (Scene$$anonymous$$anager.GetActiveScene ().buildIndex);

This is the correct way because this method takes "int" type parameter and you have to sure one thing that your all scenes have been added in build Settings.

Show more comments
avatar image
1

Answer by Cubemann · Apr 16, 2021 at 07:35 PM

Application.LoadLevel.(Application.loadedLevel); or SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 0); I don't know if this works, but SceneManager.LoadScene(SceneManager.GetActiveScene();

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

21 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

Related Questions

A node in a childnode? 1 Answer

How would I check if an object is in the scene? 1 Answer

How do I get a handle for the SceneView so I can draw in it with OpenTK? 1 Answer

I'm having trouble with my character when playing in unity, and when I build and run the game 0 Answers

large number of identical objects in scene? 3 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