Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. 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:
    176
    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,897
    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,897
    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,424
    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:
    483
    Bump! Never did figure this one out.
     
  11. Carterryan1990

    Carterryan1990

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

    XCO

    Joined:
    Nov 17, 2012
    Posts:
    341
    bump
     
  13. Prommer-Games

    Prommer-Games

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

    mukulabdagiri

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

    shahroz

    Joined:
    Jun 23, 2014
    Posts:
    1
  16. Prommer-Games

    Prommer-Games

    Joined:
    Dec 8, 2015
    Posts:
    189