Search Unity

Image sequence - place into array via script or manual insertion (loading speed issues)

Discussion in 'Scripting' started by RyanPaterson, Sep 23, 2014.

  1. RyanPaterson

    RyanPaterson

    Joined:
    Dec 14, 2013
    Posts:
    77
    Hi,

    I've created a title screen that uses image sequences. *Using unity free*

    The problem is there's about 600 images, I tried dragging them all in, but they don't get sorted by name. So I decided just to load them with script. Problem is though, it's very sluggish with speed. Estimating around 5 seconds. And this makes it look like my loading screen has crashed.

    I know there's little else I can do without the beautiful looking asynchronous functions, but I'm wondering if it would be faster to manually add them into the array?

    If that is the case, is there anyway to drag and drop in order?

    I'm using png's as well.. Not sure if that's unsuitable. I've never really had to be involved with image types.

    Thanks
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    You can write a script that sort the array for you:

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using System.Linq;
    4. using System.Collections.Generic;
    5.  
    6. public class Test : MonoBehaviour
    7. {
    8.  
    9.     public Texture[] myArray;
    10.  
    11.     [ContextMenu("Sort:myArray")]
    12.     void SortmyArray()
    13.     {
    14.         myArray = myArray.OrderByDescending(a => a.name).ToArray();
    15.     }
    16.  
    17. }
    With [ContextMenu("Sort:myArray")] you get a context menu for calling the sort function in the editor.

    If you have 600 images, keep in mind what kind of memory that 600 images eat up.
     
  3. RyanPaterson

    RyanPaterson

    Joined:
    Dec 14, 2013
    Posts:
    77

    That's cool I didn't know that. Thanks for the reply. However, would having it already placed manually, then sorting it be faster than loading it in sorted? My gut instinct is it would be a little bit faster, however i'm not too sure.
     
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    If you load the images via the www class it takes a lot more resources to load the images .
    If you only had a view images ... ok but 600 seems to much resources for no additional comfort.