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 /
  • Help Room /
avatar image
0
Question by CraftyMaelyss · Oct 19, 2016 at 05:42 AM · loading screen

My loading screen won't trigger?

I've been following this tutorial:

https://www.youtube.com/watch?v=xJQXoG3caGc

And I think I have everything working-except the trigger. I can't get the loading screen to trigger while the Play Area of my game is loading, here is a copy of the script in case someone can see where I've gone wrong:

 using System.Collections;
 using UnityEngine.SceneManagement;
 
 public class LoadingScreenManager : MonoBehaviour {
 
     [Header("Loading Visuals")]
     public Image loadingIcon;
     public Image loadingDoneIcon;
     public Text loadingText;
     public Image progressBar;
     public Image fadeOverlay;
 
     [Header("Timing Settings")]
     public float waitOnLoadEnd = 0.25f;
     public float fadeDuration = 0.25f;
 
     [Header("Loading Settings")]
     public LoadSceneMode loadSceneMode = LoadSceneMode.Single;
     public ThreadPriority loadThreadPriority;
 
     [Header("Other")]
     // If loading additive, link to the cameras audio listener, to avoid multiple active audio listeners
     public AudioListener audioListener;
 
     AsyncOperation operation;
     Scene currentScene;
 
     public static int sceneToLoad = -1;
     // IMPORTANT! This is the build index of your loading scene. You need to change this to match your actual scene index
     static int loadingSceneIndex = 4;
 
     public static void LoadScene(int levelNum) {                
         Application.backgroundLoadingPriority = ThreadPriority.High;
         sceneToLoad = levelNum;
         SceneManager.LoadScene(loadingSceneIndex);
     }
 
     void Start() {
         if (sceneToLoad < 0)
             return;
 
         fadeOverlay.gameObject.SetActive(true); // Making sure it's on so that we can crossfade Alpha
         currentScene = SceneManager.GetActiveScene();
         StartCoroutine(LoadAsync(sceneToLoad));
     }
 
     private IEnumerator LoadAsync(int levelNum) {
         ShowLoadingVisuals();
 
         yield return null; 
 
         FadeIn();
         StartOperation(levelNum);
 
         float lastProgress = 0f;
 
         // operation does not auto-activate scene, so it's stuck at 0.9
         while (DoneLoading() == false) {
             yield return null;
 
             if (Mathf.Approximately(operation.progress, lastProgress) == false) {
                 progressBar.fillAmount = operation.progress;
                 lastProgress = operation.progress;
             }
         }
 
         if (loadSceneMode == LoadSceneMode.Additive)
             audioListener.enabled = false;
 
         ShowCompletionVisuals();
 
         yield return new WaitForSeconds(waitOnLoadEnd);
 
         FadeOut();
 
         yield return new WaitForSeconds(fadeDuration);
 
         if (loadSceneMode == LoadSceneMode.Additive)
             SceneManager.UnloadScene(currentScene.name);
         else
             operation.allowSceneActivation = true;
     }
 
     private void StartOperation(int levelNum) {
         Application.backgroundLoadingPriority = loadThreadPriority;
         operation = SceneManager.LoadSceneAsync(levelNum, loadSceneMode);
 
 
         if (loadSceneMode == LoadSceneMode.Single)
             operation.allowSceneActivation = false;
     }
 
     private bool DoneLoading() {
         return (loadSceneMode == LoadSceneMode.Additive && operation.isDone) || (loadSceneMode == LoadSceneMode.Single && operation.progress >= 0.9f); 
     }
 
     void FadeIn() {
         fadeOverlay.CrossFadeAlpha(0, fadeDuration, true);
     }
 
     void FadeOut() {
         fadeOverlay.CrossFadeAlpha(1, fadeDuration, true);
     }
 
     void ShowLoadingVisuals() {
         loadingIcon.gameObject.SetActive(true);
         loadingDoneIcon.gameObject.SetActive(false);
 
         progressBar.fillAmount = 0f;
         loadingText.text = "LOADING...";
     }
 
     void ShowCompletionVisuals() {
         loadingIcon.gameObject.SetActive(false);
         loadingDoneIcon.gameObject.SetActive(true);
 
         progressBar.fillAmount = 1f;
         loadingText.text = "LOADING DONE";
     }
 
 }

I can't get it to trigger but if anyone can help me, I would greatly appreciate it :)

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

2 Replies

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

Answer by CraftyMaelyss · Oct 22, 2016 at 08:22 AM

I found out what it was, you need to create a second script (like the one he shows in the video) and then add it.

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
avatar image
0

Answer by SheZii · Jan 30, 2019 at 07:50 AM

Detailed Unity3D Actual Loading Screen Tutorial (With free C# Script and Demo project) http://techscenarios.com/2019/01/unity3d-add-loading-screen-to-your-game/

Or watch it on Youtube https://www.youtube.com/watch?v=fx9XjUS1VEQ

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

76 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

Related Questions

Why there are loading screens? 1 Answer

Infinite Loading Screen 5 Answers

NullReferenceException: Object reference not set to an instance of an object 0 Answers

How to load sceneIndex2 but run sceneIndex1 in Loading Screen? 0 Answers

Making a Loading Screen 0 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