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
0
Question by KnightRiderGuy · Nov 10, 2017 at 07:38 PM · c#scene-loadingstandalonescenes

Scene not loading in build

OK This is beyond stupid... this was all working just fine... I NEVER CHANGED ANYTHING!! This is just something new that decided to happen out of the blue!! It's set to load scene 2 although that's wrong it should be scene 3, but yet in the editor it does load the correct scene WTF?? right??

I do a standalone build and it does not load the next scene. You can see by my attachment how I have my scenes set up... has anyone had this happen before...?? Like I say I never changed anything this just suddenly decided to start happening!!

 ![using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;
 
 public class LogoMovie : MonoBehaviour {
 
     public MovieTexture movTexture;
     public RawImage myLogoMovie;
     public AudioClip KittID;
     public AudioClip LogoOutFX;
     float volume = 0.3f; //Clip Volume Setting
     public Text inputFieldPilotName;
 
     private int devSt12; //K.I.T.T. Main Intro Screen Toggle On / Off
 
     //public bool KITTID_On_Off = false; //Toggle for KITT to play ID on or off bool set to true by default.
                                       //Setable by Player Prefs from ConFig Screen
     public string mainIntroScrnTime;   //Set time for duration of main intro screen to remain before transition to main screen.
                                       //Setable by Player Prefs from ConFig Screen
 
     void Start() {
         GetComponent<RawImage>().texture = movTexture as MovieTexture;
         movTexture.Play();
         movTexture.loop = true;
 
         inputFieldPilotName = GameObject.Find("TextPilotName").GetComponent<Text>();
         inputFieldPilotName.text = PlayerPrefs.GetString("PilotName");
 
         devSt12 = PlayerPrefs.GetInt ("toggleKITTintro"); //Determins if Intro will play based on setting in Con Fig Screen.
 
         mainIntroScrnTime = PlayerPrefs.GetString ("loadScreenTime"); //Wait Time As Set By Con Fig Screen.
 
         StartCoroutine(Fade("MainScreen"));
     }
 
     IEnumerator Fade(string level02)
     {
         if (devSt12 == 1) {
             yield return new WaitForSeconds  (float.Parse(mainIntroScrnTime));
             Debug.Log ("I Am Waiting For Player Pref Time");
             GetComponent<AudioSource> ().PlayOneShot (KittID);
             Debug.Log ("I Will Play KITT Intro Because I am Set to True");
             //Load Main After Time
             yield return new WaitForSeconds (9.0f);
             myLogoMovie.CrossFadeAlpha (0, 1.0f, false);  
             GetComponent<AudioSource> ().PlayOneShot (LogoOutFX, volume);
             yield return new WaitForSeconds (0.9f);
 
             SceneManager.LoadSceneAsync (level02);
         } else {
 
             if (mainIntroScrnTime != null && mainIntroScrnTime != "")
             {
                 yield return new WaitForSeconds(float.Parse(mainIntroScrnTime));
                 Debug.Log("I Am Waiting For Player Pref Time");
                 myLogoMovie.CrossFadeAlpha(0, 1.0f, false);
                 GetComponent<AudioSource>().PlayOneShot(LogoOutFX, volume);
                 yield return new WaitForSeconds(0.9f);
             }
             else {
                 yield return new WaitForSeconds(3.0f); // DEFAULT WAIT TIME
             }
 
             SceneManager.LoadSceneAsync(level02);
         }
     }
 }][1]
 


[1]: /storage/temp/105359-screenshot-2017-11-10-133526.png

screenshot-2017-11-10-133526.png (66.7 kB)
Comment
Add comment · Show 11
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 pako · Nov 11, 2017 at 07:36 PM 1
Share

Hi @zentaiguy I may be wrong about this, but it seems to me that you got confused, because you have named the parameter of the Fade coroutine level02. Then you start the coroutine in lines 50 and 65 of your code as StartCoroutine(Fade("$$anonymous$$ainScreen")). So, in effect, the level02 parameter of the coroutine takes the value of "$$anonymous$$ainScreen", which of course, is Scene 3, per your build settings, but because the parameter name is level02, you might be thinking that it's set to load scene 2, which is not the case! I was very confused too by this. $$anonymous$$aybe it would be a good idea to rename the parameter of the Fade coroutine to something else, like "level03", or even better "mainScreen".

However, I don't understand the second part of your question "I do a standalone build and it does not load the next scene". Which is the next scene? and if that doesn't load, which scene loads? Do you perhaps mean that the "$$anonymous$$ainScreen" doesn't load as expected from lines 50 and 65? Please clarify what you mean. It's not clear what works and what doesn't.

avatar image KnightRiderGuy pako · Nov 14, 2017 at 04:22 PM 0
Share

Sorry for the late response @pako Yeah that 2nd part is a little convoluted, I apologize for that. What I was trying to say was even with the code appearing to be wrong it loads the correct scene in the unity editor but not in the stand alone build.... even stranger is that even in the stand alone build this had been working long before, I had not changed it as it had been working but like you say the code is wrong and tries to load the wrong scene 02 when it should be 03.... but stage as it seems this had been working from day one when I started this project 3 years ago.... so I can't figure that out even.... makes no sense ???

avatar image pako KnightRiderGuy · Nov 14, 2017 at 05:13 PM 0
Share

@zentaiguy does my response help you understand why this is happening in the editor? Because, in your question you say:

It's set to load scene 2 ...

... but as far as I can see, that statement is wrong! you have actually set to load scene 3!!! as I explain in my reply. So, everything is working as it should! I thought my reply was clear, but it seems that you might need some clarifications. Please tell me what you don't understand in my reply above. To put it more simply, it doesn't matter what you have named the parameter of the Fade coroutine. You have named it level02:

 IEnumerator Fade(string level02)


You could have named it anything, e.g. sceneToLoad:

 IEnumerator Fade(string sceneToLoad)

What matters, is the string value that you use when you start the coroutine "$$anonymous$$ainScreen":

 //Line 34 of your posted code -- this is the scene you are setting to load
 StartCoroutine(Fade("$$anonymous$$ainScreen")); //"$$anonymous$$ainScreen" corresponds to scene 3 in your Build Setting, not scene 2!

EDIT: So, in lines 50 and 65 of your posted code, you are loading scene 3, because level02 = "$$anonymous$$ainScreen":

 Scene$$anonymous$$anager.LoadSceneAsync(level02);
 //is the same as:
 Scene$$anonymous$$anager.LoadSceneAsync ("$$anonymous$$ainScreen"); // level02 = "$$anonymous$$ainScreen" = Scene 3 in Build Settings

So, in the editor nothing's wrong, everything works as it should! But what about the standalone build, what scene loads up in the standalone build, and when does it load that?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KnightRiderGuy · Nov 14, 2017 at 07:48 PM

@pako @pako I have not tested it out side of the editor yet in a build but I think this might by pass it not having any preset values... I think it's kind of a catch 22 going on, the player can't set vales if they can't get in so it needs to bypass on the very first start up.

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;
 
 public class LogoMovie : MonoBehaviour {
 
     public MovieTexture movTexture;
     public RawImage myLogoMovie;
     public AudioClip KittID;
     public AudioClip LogoOutFX;
     float volume = 0.3f; //Clip Volume Setting
     public Text inputFieldPilotName;
 
     private int devSt12; //K.I.T.T. Main Intro Screen Toggle On / Off
 
     //public bool KITTID_On_Off = false; //Toggle for KITT to play ID on or off bool set to true by default.
                                       //Setable by Player Prefs from ConFig Screen
     public string mainIntroScrnTime;   //Set time for duration of main intro screen to remain before transition to main screen.
                                       //Setable by Player Prefs from ConFig Screen
 
     void Start() {
         GetComponent<RawImage>().texture = movTexture as MovieTexture;
         movTexture.Play();
         movTexture.loop = true;
 
         inputFieldPilotName = GameObject.Find("TextPilotName").GetComponent<Text>();
         inputFieldPilotName.text = PlayerPrefs.GetString("PilotName");
 
         devSt12 = PlayerPrefs.GetInt ("toggleKITTintro"); //Determins if Intro will play based on setting in Con Fig Screen.
 
         mainIntroScrnTime = PlayerPrefs.GetString ("loadScreenTime"); //Wait Time As Set By Con Fig Screen.
 
         StartCoroutine(Fade("MainScreen"));
     }
 
     IEnumerator Fade(string level03)
     {
         if (devSt12 == 1) {
             yield return new WaitForSeconds  (float.Parse(mainIntroScrnTime));
             Debug.Log ("I Am Waiting For Player Pref Time");
             GetComponent<AudioSource> ().PlayOneShot (KittID);
             Debug.Log ("I Will Play KITT Intro Because I am Set to True");
             //Load Main After Time
             yield return new WaitForSeconds (9.0f);
             myLogoMovie.CrossFadeAlpha (0, 1.0f, false);  
             GetComponent<AudioSource> ().PlayOneShot (LogoOutFX, volume);
             yield return new WaitForSeconds (0.9f);
 
             SceneManager.LoadSceneAsync (level03);
         } 
         if (devSt12 == 0) {
 
             if (mainIntroScrnTime != null && mainIntroScrnTime != "")
             {
                 yield return new WaitForSeconds(float.Parse(mainIntroScrnTime));
                 Debug.Log("There Was No Player Pref Time Set");
                 myLogoMovie.CrossFadeAlpha(0, 1.0f, false);
                 GetComponent<AudioSource>().PlayOneShot(LogoOutFX, volume);
                 yield return new WaitForSeconds(3.0f);
                 SceneManager.LoadSceneAsync(level03);
             }
             
         }
         else {
             Debug.Log ("I Could Find No Values To Work With");
             yield return new WaitForSeconds(3.0f); // DEFAULT WAIT TIME
             SceneManager.LoadSceneAsync(level03);
         }
     }
 }
 


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 pako · Nov 15, 2017 at 10:48 AM 0
Share

@zentaiguy did it work on the standalone build? Also, it might be a good idea to provide some default values, which the player can change as soon as he gets the chance. e.g set some values in Start(), and then it's up to the player to change them.

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

419 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 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 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 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 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 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

Adding to delegate with multiple instances of the same object 1 Answer

UI canvas or panel that only appears once per game session? 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Transition between levels using 2d colider works once but not repeatidly. 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