Search Unity

What is the best way to load textures and videos dynamically?

Discussion in 'Editor & General Support' started by Sahkan, May 27, 2019.

  1. Sahkan

    Sahkan

    Joined:
    Mar 3, 2013
    Posts:
    204
    Let's say I have a game that is viewing textures and videos on demand on a quad mesh.

    One way is using the Resources folder.

    The other is to drag all of the textures and video into the inspector to a StorageManager.

    The first way is more convenient but everybody advises against using the resources folder.

    The second way is annoying to implement and it will cause all of those textures and videos to load when that StorageManager is loaded whether I need them or not. (causes longer loading time of the scene).

    *Notice I want those textures and videos to ship with the build so AssetBundles are not a very comfortable option.

    So what is the best way to implement such a system?
     
  2. Sahkan

    Sahkan

    Joined:
    Mar 3, 2013
    Posts:
    204
    Bump...
     
  3. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    Maybe try StreamingAssets folder, and load from actual folder?
     
  4. Sahkan

    Sahkan

    Joined:
    Mar 3, 2013
    Posts:
    204
    How is that better than using the resources folder?
     
  5. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    You can load stuff on demand.
    You can keep files outside resource folder.
    You can modify / add / remove files easily, even after game compilation.
     
  6. Sahkan

    Sahkan

    Joined:
    Mar 3, 2013
    Posts:
    204
    I see.
    What if I want to hide those assets from the user (I don't want him to be able to edit the textures and videos).
    Thanks.
     
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    This is what resource folder is for.
    But true is, anyone who wants to, can extract both media files and scripts.