Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

How does "Preloaded Assets" in Player Settings Work?

Discussion in 'Documentation' started by alan-lawrance, Apr 12, 2015.

  1. alan-lawrance

    alan-lawrance

    Joined:
    Feb 1, 2013
    Posts:
    206
    Unity 5 has a new field in the Optimization section of "Other Settings" for Standalone builds:

    Preloaded Assets

    I've been unable to find any documentation that explains how this works. Presumably the memory you allocate for this gets used to permanently load assets, but is there any way to know which ones?

    Edit: Never mind, I see the "Size" is the number of array elements, and you can specify a list of assets. I had assumed the Size was a memory value in bytes.
     
    Last edited: Apr 12, 2015
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    2,942
    You're correct that this is not documented at all, we just used it without even thinking about it too much.

    When we ported our game to WebGL, we used streaming. This means that not all scenes and data is loaded when the game is already playable.

    As such, it may be possible that you get into scenarios where a scene was loaded but some assets it needs that are loaded dynamically (e.g: Resources.Load) will not be ready.

    To avoid this, we added these assets to "Preloaded assets". The engine then makes sure these will be ALWAYS AVAILABLE from the second the game starts.

    We did this for a couple of important data assets that had to be used early on in the game initialization.
     
    alan-lawrance likes this.
  3. ScorpioGamer

    ScorpioGamer

    Joined:
    Oct 14, 2012
    Posts:
    5
    @liortal So using "Resources.load" will not give any hiccups if you preload them via build settings?
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    2,942
    Depends on what you mean by "hiccups".
    That setting means that the player will handle loading these assets by itself, before the player starts.

    This will add some loading time of course.
     
  5. ScorpioGamer

    ScorpioGamer

    Joined:
    Oct 14, 2012
    Posts:
    5
    occasionally i get spikes when i use "Resoures.load" for the first time, i use pooling after that. So i think preloading might help me there.
     
  6. itheark

    itheark

    Joined:
    Jul 1, 2015
    Posts:
    2
    Did it help by preloading or do i have pool the assets ??
     
  7. ScorpioGamer

    ScorpioGamer

    Joined:
    Oct 14, 2012
    Posts:
    5
    you will still have to pool it.
     
  8. Ratboy601

    Ratboy601

    Joined:
    Jun 22, 2014
    Posts:
    29
    So I assigned some models to my preloaded assets, and then they showed up blue (no texture/material) in game. So I removed them. Now they are still blue. Any ideas how to fix this?

    ========EDIT===============

    It would appear this problem had something to do with my changes to the vertex compression settings, or something else in the Optimization GUI, and not the preloaded assets at all. Thanks anyway!
     
    Last edited: Oct 23, 2015
  9. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,434
    Do you mean ScriptableObjects?

    I have added a couple of ScriptableObjects to the Preloaded Assets list but they are not being loaded at player start up (their OnEnable is not being called).
     
  10. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    500
    Bump! Never did figure this one out.
     
  11. Carterryan1990

    Carterryan1990

    Joined:
    Dec 29, 2016
    Posts:
    39
  12. XCO

    XCO

    Joined:
    Nov 17, 2012
    Posts:
    343
    bump
     
  13. UnityUser9860

    UnityUser9860

    Joined:
    Dec 8, 2015
    Posts:
    182
  14. mukulabdagiri

    mukulabdagiri

    Joined:
    Jul 1, 2016
    Posts:
    11
  15. shahroz

    shahroz

    Joined:
    Jun 23, 2014
    Posts:
    1
  16. UnityUser9860

    UnityUser9860

    Joined:
    Dec 8, 2015
    Posts:
    182
  17. exzizt

    exzizt

    Joined:
    Sep 30, 2017
    Posts:
    11
    Bump party!
     
  18. Carterryan1990

    Carterryan1990

    Joined:
    Dec 29, 2016
    Posts:
    39
    lmao unity is trolling us
     
    FlopCoat likes this.
  19. E2R_Ben

    E2R_Ben

    Joined:
    Oct 30, 2009
    Posts:
    139
    (bump?!) Would this work for assets in the streaming assets folder in a web GL build? I have a small bug where videos in my web gl project get stuck loading (they are all streamed through streaming assets) and wondered if this would fix it.