Search Unity

Download when launch the app

Discussion in 'Addressables' started by MomochaZ, Jan 25, 2019.

  1. MomochaZ

    MomochaZ

    Joined:
    Jun 20, 2013
    Posts:
    28
    Hi

    I an trying to download and show progress when launch the app.
    I divid my assets into some labels and record all the labels into scriptable objects.
    When I launch app,I will load the label record and load asseets with labels.
    how do I load all assets with label and release it.
    Here is my code

    Addressables.LoadAssets<Object>(labelName, OnDownloadSingleAssetComplete).Completed += OnDownloadSingleLabelDataComplete;

    private void OnDownloadSingleAssetComplete(IAsyncOperation<Object> op)
    {
    if(op.Status == AsyncOperationStatus.Succeeded)
    {
    Addressables.ReleaseAsset(op.Result);
    }
    }

    private void OnDownloadSingleLabelDataComplete(IAsyncOperation<IList<Object>> op)
    {
    if(op.Status == AsyncOperationStatus.Succeeded)
    {
    UpdateDownloadProgress();
    }
    }


    Is will this way will load all the assets from labels?
    Is the completed callback can release all the assets?
    Because I will get an error shows
    If there is scene and prefab data use the same label,I will also get error
    Now I think about the solution is I have to divid scene data label and other data label.
    Use LoadScene to load scene label and LoadAssets for other assets.

    Is someone can share about how to do this?

    Does addressable will provide more convenient funtion to predownload assets in next version?

    Thanks.
     
    Last edited: Jan 25, 2019
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    the next version will have a DownloadDependencies method, as well as one to query total download size in advance.