Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

WebGL remote download material problem

Discussion in 'Addressables' started by BlasterDm, Apr 8, 2020.

  1. BlasterDm

    BlasterDm

    Joined:
    Aug 28, 2018
    Posts:
    6
    Hello. I am new to using addressables and have been working with them for only 2 weeks now. So now I am kinda stuck with my prefabs remote downloading. The problem is that it seems prefabs materials are not downloaded correctly on WebGL build platform. I just made several prefabs of default 3D objects and tried to download them by label using following script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.AddressableAssets;
    5. using UnityEngine.ResourceManagement.ResourceLocations;
    6. using System;
    7. using UnityEngine.ResourceManagement.AsyncOperations;
    8.  
    9. public class PrefabsDownloader : MonoBehaviour
    10. {
    11.     [SerializeField]
    12.     private string modelsLabel;
    13.  
    14.     private List<GameObject> instantiatedModels = new List<GameObject>();
    15.  
    16.     public void SpawnModels()
    17.     {
    18.         LoadPrefabs(InstantiatePrefabs);
    19.     }
    20.  
    21.     public void LoadPrefabs(Action<AsyncOperationHandle<IList<GameObject>>> onLoaded)
    22.     {
    23.         Addressables.LoadAssetsAsync<GameObject>(modelsLabel, null).Completed += onLoaded;
    24.     }
    25.  
    26.     public void InstantiatePrefabs(AsyncOperationHandle<IList<GameObject>> prefabsDownloadHandle)
    27.     {
    28.         if (prefabsDownloadHandle.Status == AsyncOperationStatus.Succeeded)
    29.         {
    30.             IList<GameObject> prefabs = prefabsDownloadHandle.Result;
    31.  
    32.             foreach (GameObject prefab in prefabs)
    33.             {
    34.                 instantiatedModels.Add(Instantiate(prefab));
    35.             }
    36.         }
    37.     }
    38.  
    39.     void Start()
    40.     {
    41.         SpawnModels();
    42.     }
    43. }
    The result I got you can find among attached files. This seems to be exclusive for WebGL because on MacOS build platform everything was downloaded correctly.
     

    Attached Files:

  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,799
    I'll flag this for the team to have a look. Which version of Addressables and the editor are you using?
     
  3. BlasterDm

    BlasterDm

    Joined:
    Aug 28, 2018
    Posts:
    6
    Hello, I am using Unity 2019.3.2f1, addressables - 1.7.5.
     
  4. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,799