Search Unity

Just started using addressables, some folder problems

Discussion in 'Addressables' started by DevilCult, Feb 6, 2020.

  1. DevilCult

    DevilCult

    Joined:
    Jun 24, 2017
    Posts:
    62
    Hey guys, so i just installed the addressables packages after being impressed of what it does but i ran in some problems.

    First, i started a project long ago and added all into the ressources folder (the nightmare.). Didn't really care to read about assetbundle until recently which made me find the addressable package so i wanted to convert all my ressources folder into assetbundles. So once i loaded addressables, i had a BuiltIn hierarchy which contains Ressources with all my stuff in it. Things are in folder, and subfolder, some are straight in the ressources folder. Those that were straight in folder can be moved to a assets pack easily. But the folder/subfolder inside ressources keep hanging my unity (2019.3.06f) with some treeview error when i tried to move each of them. Had to force close unity and reload it for each folder i had in ressources, which took a good hour. So that was the first problem.

    Now that i have everything moved, i saw that the gameobject/folder are checked with Addressables on the gameobject view, but the objects inside folder arent.

    Now my question is do i need to check the objects inside those folder as addressables if the folder is checked addressables itself? There a ton of stuff in that. Maybe it should have been marked automatically while moving it? (Or maybe thats what caused unity to hang up?)

    Anyway beside that, i'm still very happy to go forward with this new tools! Lot of possibilities! Thanks alot :)

    edit: im Also seeing a version 1.6.0 but i got the 1.1.10, should i update to 1.6.0?
     
    Last edited: Feb 6, 2020
  2. DevilCult

    DevilCult

    Joined:
    Jun 24, 2017
    Posts:
    62
    Another question, i changed a folder name in project hierarchy (cant seem to find where to change the path name in addressables), so im wondering if its possible to change it? Or do i have to delete it from the addressable and then recheck the folder/objects inside. (As everything got moved from Resources to Resources_Moved for addressables, just wanted to name it MyAssets)
     
  3. DevilCult

    DevilCult

    Joined:
    Jun 24, 2017
    Posts:
    62
    Ok got it all to work and cleaned everything, also updated to 1.6.0 ... that was insanity in a short amount of time.

    And 3 problems surged.

    1. First im trying to retrieve the size of download before doing anything. I'm doing it this way which always return 0 whatever i do. What am i doing wrong?

    Code (CSharp):
    1. Addressables.GetDownloadSizeAsync(preloadLabel.labelString).Completed += test => { Debug.Log("Download size: " + test.Result); };
    2. When loading sound file (My project is WebGL) in the play mode "Use Existings Build", im getting a bunch of error for my sounds/musics like this (they are mixed files, ogg, mp3, wav):

    Error: Cannot create FMOD::Sound instance for clip "foodeat" (FMOD error: Unsupported file or audio format. )

    followed by:

    Error: Cannot load audio data for audio clip "Bottle"

    3. This is not really a problem but more of the idea behind the whole process im doing and i want know if im doing things the right way.

    Take notes of the 2 comments (1. and 2.) i wrote and tell me if im wrong!

    Code (CSharp):
    1. public class Preloader : MonoBehaviour
    2. {
    3.     public Text _textpercent;
    4.     public Slider _slider;
    5.     private int percent;
    6.  
    7.     private AsyncOperationHandle op;
    8.     public AssetLabelReference preloadLabel;
    9.     List<IResourceLocation> preloadLocations;
    10.  
    11.     void Start()
    12.     {
    13.         //1. This should preload everything labeled 'preload' in memory and give a percentcomplete progress.
    14.         op = Addressables.DownloadDependenciesAsync(preloadLabel.labelString);
    15.         //Addressables.GetDownloadSizeAsync(preloadLabel.labelString).Completed += test => { Debug.Log("Result2: " + test.Result); }; //not working?
    16.     }
    17.  
    18.     private void Update()
    19.     {
    20.         if (op.IsValid())
    21.         {
    22.             Debug.Log(op.PercentComplete); //its going fast, so im trying to catch the percentage number here which seem to work i see it jump to 0.6 then 1. Using ongui would probably be better.
    23.             _textpercent.text = string.Format("Loading: {0}%", (int)(op.PercentComplete * 100));
    24.             _slider.value = op.PercentComplete;
    25.             if (op.PercentComplete == 1)
    26.             {
    27.                 Addressables.Release(op);
    28.                 //op = new AsyncOperationHandle();
    29.                 LoadScenes(); //once completed, run the scene
    30.             }
    31.         }
    32.     }
    33.  
    34.     private void LoadScenes()
    35.     {
    36.         //2. getting locations of everything (which should be already in memory) to get a count of the items preloaded.
    37.         Addressables.LoadResourceLocationsAsync(preloadLabel.labelString).Completed += OnScenesLoaded;
    38.     }
    39.  
    40.     private void OnScenesLoaded(AsyncOperationHandle<IList<IResourceLocation>> op)
    41.     {
    42.         if (op.Status == AsyncOperationStatus.Failed)
    43.         {
    44.             Debug.Log("Failed to load scenes, retrying in 10 second...");
    45.             Invoke("LoadScenes", 10);
    46.             return;
    47.         }
    48.         preloadLocations = new List<IResourceLocation>(op.Result);
    49.         Debug.Log("Count: " + preloadLocations.Count); //This show the numbers of asset loaded, 15 items + 2 group = 17
    50.         Addressables.LoadSceneAsync("Login");
    51.     }
    52. }
    With this code loaded in, i can now switch to scene "Login" and from there load any scene or work with stuff i previously preloaded in the preload scene cause its still in memory/cache.

    Also there a few bugs: The more stuff being loaded into the Addressables panel, the laggier it get. When i click a button, i gotta move the mouse a bit to make the menu appear? Also because there is more and more item being added, everytime i label an item it take like 2-3 seconds before completing and have it show in the label bar.

    Any help would be appreciate! :)
     
    Last edited: Feb 7, 2020
  4. DevilCult

    DevilCult

    Joined:
    Jun 24, 2017
    Posts:
    62
    Found my sounds problem: https://forum.unity.com/threads/aud...bgl-when-downloaded-with-assetbundles.377103/

    Very old thread talking about it. If i open the project compiled in the browser it work fine, in editor there is not way to get it to work. So WebGL user can't really use that "Use Existings Build" play mode in editor. I did try overriding setting to make sure its AAC and everything it just doesnt want to go.