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 DarkOfNight · Apr 01, 2015 at 11:51 AM · scene-loadingscript errorscene-switchingscene-change

How use the function Application.LoadLevelAsync(level);

Hello, I'm French and I speak a little enclish (I use Google traduction).

I try use the function Application.LoadLevelAsync, but the loading my scene does not exceed 90%.

Can you help? Thanks

This is my class (C#) :

 using System;
 using System.Collections;
 using System.Diagnostics;
 using UnityEngine;
 using UnityEngine.UI;
 public class Loading : MonoBehaviour
 {
     public GameObject _Loading;
     private Image _backgroundImage;
     private Text _Text;
     private Text _OmbreText;
     private Image _Chargement;
     private float _currentAlpha = 0.0f;
     private GameObject _currentPanel;
     private String _type;
     private int _Term = 0;
 
     private void Awake()
     {
         DontDestroyOnLoad(gameObject);
         Global.loading = this;
     }
 
 
     public void StartShowPanel(String type)
     {
         _type = type;
 
         StartCoroutine("ShowPanel");
     }
 
     private IEnumerator ShowPanel(){
 
         
         InstantiateLoadPanel ();
 
         while (_currentAlpha < 1) {
                         yield return new WaitForSeconds (0.035f);
             _currentAlpha += 0.25f; 
             _Chargement.color = new Color (_Chargement.color.r, _Chargement.color.g, _Chargement.color.b, _currentAlpha);
             _backgroundImage.color = new Color (_backgroundImage.color.r, _backgroundImage.color.g, _backgroundImage.color.b, _currentAlpha);
             _Text.color = new Color (_Text.color.r, _Text.color.g, _Text.color.b, _currentAlpha);
             _OmbreText.color = new Color (_OmbreText.color.r, _OmbreText.color.g, _OmbreText.color.b, _currentAlpha);
                 }
         DoAction ();
 
         }
 
     private IEnumerator HidePanel(){
         
         _Term = 1;
         while (_currentAlpha > 0) {
             yield return new WaitForSeconds (0.035f);
             _currentAlpha -= 0.25f; 
             
             _Chargement.color = new Color (_Chargement.color.r, _Chargement.color.g, _Chargement.color.b, _currentAlpha);
             _backgroundImage.color = new Color (_backgroundImage.color.r, _backgroundImage.color.g, _backgroundImage.color.b, _currentAlpha);
             _Text.color = new Color (_Text.color.r, _Text.color.g, _Text.color.b, _currentAlpha);
             _OmbreText.color = new Color (_OmbreText.color.r, _OmbreText.color.g, _OmbreText.color.b, _currentAlpha);
         }
         _Term = 2;
         Destroy (_currentPanel);
 
     }
 
     private void InstantiateLoadPanel()
     {
         _currentPanel = Instantiate<GameObject>(_Loading);
         if (_currentPanel == null)
         {
             return;
         }
         
         _Chargement = _currentPanel.transform.FindChild("Chargement").FindChild("Chargement_Image").GetComponent<Image>();
         _backgroundImage = _currentPanel.transform.FindChild("Image").GetComponent<Image>();
         _Text = _currentPanel.transform.FindChild("Text").GetComponent<Text>();
         _OmbreText = _currentPanel.transform.FindChild("OmbreText").GetComponent<Text>();
         DontDestroyOnLoad(_currentPanel);
     }
     private void DoAction()
     {
 
         StartCoroutine("LevelLoaderProcess");
     }
 
     public float pourcent = 0.0f;
     public bool doneLoadingScene = false;
 
     IEnumerator LevelLoaderProcess() {
         AsyncOperation status = Application.LoadLevelAsync(_type);
         status.allowSceneActivation = false;
 
 
 
         
         while (!status.isDone && !doneLoadingScene) {
             yield return new WaitForSeconds(0.35f);
             pourcent = status.progress * 100f;
             _Chargement.transform.Rotate (0, 0, 0.25f);
 
             
             if(status != null && !doneLoadingScene) 
             {  
                 print("Scene Load Progress: " + status.progress * 100f); 
                 if(status.isDone) 
                 {  
                     doneLoadingScene = true; 
                     print("SCENE DONE LOADING!"); 
                 }  
             }  
 
 
         }
         status.allowSceneActivation = true;
         // Allow new scene to start.
         StartCoroutine("HidePanel");yield return status;
     }
 
 
 
 }
 

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KdRWaylander · Apr 03, 2015 at 11:50 AM

Here you go :)

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Using parameters of activeSceneChanged? 0 Answers

How Do I Link Different Scenes? 4 Answers

Is there any ideas to load Unity scene asynchronously? 1 Answer

Whenever i load scene 2 after completing scene 1 there is a tremendous drop in fps it is showing only 0.1 fps 1 Answer

Unity Scene loading problem (slow loading until it freezes) 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