Search Unity

How do you use Resources.LoadAsync with a multiple frame sprite?

Discussion in '2D' started by aitchest-of-dees, Nov 3, 2016.

  1. aitchest-of-dees

    aitchest-of-dees

    Joined:
    Dec 28, 2013
    Posts:
    73
    I am trying to load all my sprites asynchronously and it works for single frame sprites, but if the sprite is setup to Sprite Mode: Multiple, only the first frame is loaded. All the answers I've found for loading multiple-frame sprites is to use Resources.LoadAll, which is what I was doing before. As there is no " Resources.LoadAllAsync" command, how do you load multiple frame sprites asynchronously?

    Code (CSharp):
    1.  resourceRequest = Resources.LoadAsync<Sprite>(loadPath);//path to multiple sprite mode sprite
    2. while (!resourceRequest.isDone)
    3. {
    4.      yield return 0;
    5. }
    6. sprite = (Sprite)resourceRequest.asset;//contains frame 0
     
  2. aitchest-of-dees

    aitchest-of-dees

    Joined:
    Dec 28, 2013
    Posts:
    73
    Well I've given up ,and separated all my sprite folders into single frame sprite folders and multi-frame sprite folders, and call a totally different method to load the multi-frame sprites the old way. This is very messy and annoying, since the idea of async loading is to spread out the slowest loading times during the logo screen so they don't make the game choppy or have a long load time between scene changes -- and multi-frame sprites are usually the largest sprite files to load. Unhappy, but moving on.
     
    IgorAherne likes this.
  3. IgorAherne

    IgorAherne

    Joined:
    May 15, 2013
    Posts:
    393
    literally
    bumped into this issue 5 minutes ago.
    love how those things get on the way of programming and we waste several hours instead of advancing in our project
     
  4. Vivien_Lynn

    Vivien_Lynn

    Joined:
    May 17, 2019
    Posts:
    19
    I am a bit late, but maybe you need to try to assign the result to a sprite-array, when the SpriteMode is set to Multiple.
     
  5. aitchest-of-dees

    aitchest-of-dees

    Joined:
    Dec 28, 2013
    Posts:
    73
    The result already is an array of Sprites: The List of Sprites that gets loaded from the folder (unity 5):

    Code (CSharp):
    1. Sprite[] spriteList = Resources.LoadAll<Sprite>(folder);