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 mamadouad09 · Nov 03, 2019 at 03:46 AM · assetbundlescene-loadingscenesassetdatabaseaddress

How to Load a scene from addressable on the preloading scene without changing scenes?,How do I preload an addressable scene without changing the scene?

I want to preload the scene from the addressables and keep it without changing scenes. Addressables.LoadSceneAsync("sceneName"); does load but it changes the scenes as soon as it finishes. I don't want that. I just want to load it on the preloading scene, then use that to load the scene when I press the button for it.

Please help, it is very urgent. Best Regards.,I want to preload a scene that has been marked as addressable without it changing scene. Maybe be saving on some type of variable. And than referencing to that scene whenever I want to get to the scene.

I want to achieve something like this in the preloader. But I don't want to change the scene right away. Addressables.LoadSceneAsync("sceneName");

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
1

Answer by wigglypuffs · Dec 25, 2019 at 11:29 AM

@mamadouad09

 public string NextScene = "MainMenu";
 public AssetReference Level;
 
 long downloadSize;
 AsyncOperationHandle asyncHandle;
 
 void Awake()
 {
     if (Level.RuntimeKeyIsValid() Addressables.GetDownloadSizeAsync(Level.RuntimeKey).Completed += GetDownloadSize_Completed;
 }
 
 void GetDownloadSize_Completed(AsyncOperationHandle<long> obj)
 {
     if (obj.IsValid())
     {
         downloadSize = obj.Result;
         asyncHandle = Addressables.DownloadDependanciesAsync(Level.RuntimeKey);
         asyncHandle.Completed += Preloader_Completed;
     }
 }
 
 void Preloader_Completed(AsyncOperationHandle obj)
 {
     if (obj.IsValid())
     {
         if (obj.Result != null) SceneManager.LoadScene(NextScene, LoadSceneMode.Single);
     }
 }
 
 void Update()
 {
     // Do your progress bar updates here... etc
 }

Note: Download size can be 0 if the content is already cached so don't rely on the size. The size can be useful in determining how far along you are, for example you can display in a text box:

 if (asyncHandle.IsValid())
     status.text = $"{asyncHandle.PercentComplete * downloadSize} / {downloadSize}";

Though, I've found it not to be entirely accurate. You might want to remap the range or something, in my case I found that 0.18 to 0.48 percent is the true range. I'm not entirely certain why.

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
1

Answer by laurentlavigne · Aug 04, 2020 at 03:32 AM

@mamadouad09

 var loadAsync = Addressables.LoadSceneAsync("sceneName", activateOnLoad=true);

then when you're ready to activate:

 loadAsync.Result.Activate();
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

125 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

Related Questions

CheckConsistency: GameObject does not reference component Animator. Fixing. 0 Answers

AssetReference.LoadSceneAsync(LoadSceneMode.Additive); stops at 95% in the editor when the Play Mode Script is Use Existing Groups. 0 Answers

Load a scene from AssetBundle 0 Answers

Addressables - Use Asset Database (faster) - Not loading assets within a folder 1 Answer

Does the Singleton GameObject need to be in all scenes where i need to access it? 2 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