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 /
avatar image
1
Question by importguru88 · Aug 14, 2016 at 06:08 PM · scenescene-loadingscene-switching

How do I return scene using bulid index scenemanager in c#

I am having a problem is when timer reaches zero it reloads the current scene. I want to reload a different scene . I tried application load , scene manager load scene and nothing happens. Here is what I got for code :

   else
                      {
                       SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 
  
                      }
                 }
      }
  }
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 Addyarb · Aug 14, 2016 at 08:34 PM 0
Share

What's the name of the scene you're trying to load? This code that you've posted does indeed just reload the current scene.

avatar image Ragequit0605 · Aug 15, 2016 at 03:03 PM 0
Share

When going into FILE>BUILD_SETTINGS , check which scene you want to load. You should see a number next to a scene. Use that number in application.LoadLevel(TheSceneNumberHere); I know you said you tried it but i'm not sure if you enabled the scene too. $$anonymous$$ake sure that checkbox is ticked. If you haven't added the scene to the list already, open your desired scene and click the "Add open scenes" button in the BuildSettings window.

2 Replies

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

Answer by Jessespike · Aug 15, 2016 at 01:59 PM

To load the next scene in the build index, you can add "+1" after the current buildIndex:

 SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);

It can be stored as an int, if you wish:

 int nextBuildIndex = SceneManager.GetActiveScene().buildIndex + 1;
 SceneManager.LoadScene(nextBuildIndex);

If a specific scene needs to be loaded, then it needs to be specified:

 //examples
 SceneManager.LoadScene("NameOfNewScene");    
 SceneManager.LoadScene(3);
Comment
Add comment · Show 3 · 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 importguru88 · Aug 15, 2016 at 02:54 PM 0
Share

I tried Scene$$anonymous$$anager.LoadScene("NameOfNewScene");
Scene$$anonymous$$anager.LoadScene(3); they didn't work .

avatar image importguru88 · Aug 15, 2016 at 02:55 PM 0
Share

Here is what I got for code now :

 using UnityEngine; 
 using System.Collections; 
 using UnityEngine.UI; 
 using UnityEngine.Scene$$anonymous$$anagement;
 
 public class TestScript : $$anonymous$$onoBehaviour 
 { 
     public $$anonymous$$yClockScript myClock; 
     public Score$$anonymous$$anagerScript scoremanager; 
     public int scoreToReach = 99; // change this value to what you want 
     public string nextScene = "FY"; // change this value to what you want
 
     
     void Update () 
      {
       if (myClock.m_leftTime <= 0)
    {
      if ((Score$$anonymous$$anagerScript.score >= scoreToReach) &&
          (Scene$$anonymous$$anager.GetActiveScene().buildIndex + 1 < Scene$$anonymous$$anager.sceneCountInBuildSettings))//checking if there is a next scene
      {
        Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiveScene().buildIndex + 1);//load scene with next scene index
      }
      else
      {
        Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiveScene().buildIndex);//load scene with current scene index/general reload
      }
         Scene$$anonymous$$anager.LoadScene(Scene$$anonymous$$anager.GetActiveScene().buildIndex + 2);//load scene with next scene index
                     
 
 
 
                      }
                 }
      }
  
avatar image importguru88 · Aug 15, 2016 at 02:58 PM 0
Share

I am trying to load gy in the pic alt text

scene-2.png (247.0 kB)
avatar image
0

Answer by maurogsw · Jul 24, 2019 at 07:44 PM

I have a Problem two , so i use binary files to save evrything but i save the int currentLevel and set that equal to the current buildindex so now i want to load with SceneManager currentLevel.

Any solutions?

Thanks

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

57 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

Related Questions

Scene Loading Issue. 0 Answers

Can't find game object / script after scene re-enter 1 Answer

Does Active/Inactive and Enabled/Disabled save memory? 1 Answer

Multiple Scenes: Are previous scenes still active after you call a new scene? 1 Answer

Canvas gets invisble after changing scene 1 Answer


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