Search Unity

UnityWebRequest

Discussion in 'Asset Bundles' started by btckey, Jun 5, 2019.

  1. btckey

    btckey

    Joined:
    Nov 1, 2012
    Posts:
    40
    Hello

    I am using Unity 2019.1.5f1 (64-bit version)
    I'm having difficulty loading the bundle

    I use to create

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3.  
    4. public class CreateAssetBundles : MonoBehaviour
    5. {
    6.     [MenuItem("Assets/Create Asset Bundle")]
    7.     static void BuildAllAssetBundles()
    8.     {
    9.         BuildPipeline.BuildAssetBundles("Assets/Editor/Build", BuildAssetBundleOptions.ChunkBasedCompression, BuildTarget.WebGL);
    10.     }
    11. }
    For loading

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Networking;
    3. using System.Collections;
    4.  
    5. public class BundleLoaderOne : MonoBehaviour
    6. {
    7.     void Start()
    8.     {
    9.         StartCoroutine(LoadBundle());
    10.     }
    11.  
    12.     IEnumerator LoadBundle()
    13.     {
    14.         using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle("http://server.ru/games/assets/bundles/parapet_cube"))
    15.         {
    16.             yield return uwr.SendWebRequest();
    17.  
    18.             if (uwr.isNetworkError || uwr.isHttpError)
    19.             {
    20.                 Debug.Log(uwr.error);
    21.             }
    22.             else
    23.             {
    24.                 AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr);
    25.  
    26.                 GameObject myPrefab = bundle.LoadAsset<GameObject>("parapet_cube");
    27.  
    28.                 Instantiate(myPrefab);
    29.             }
    30.         }
    31.     }
    32. }
    when I test the code in the editor, I have no errors and the build loads fine
    when I upload everything to the server 3dlove.ru/games/assets/bundles/parapet_cube, everything stops working for me

    who can tell what i'm doing wrong
    thank
     
    Last edited: Jun 12, 2019
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    When I go that URL in my browser, I get 404 error. If it's that what you get, then it works as expected, hosting issue.
     
  3. btckey

    btckey

    Joined:
    Nov 1, 2012
    Posts:
    40
    Last edited: Jun 12, 2019
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Now the link works for me too. What error do you get?
     
  5. btckey

    btckey

    Joined:
    Nov 1, 2012
    Posts:
    40
    An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:
     
    Last edited: Jun 12, 2019
  6. btckey

    btckey

    Joined:
    Nov 1, 2012
    Posts:
    40
    I uploaded the assembly to another Amazon hosting, the error remained
     
  7. btckey

    btckey

    Joined:
    Nov 1, 2012
    Posts:
    40
    in all this time I have tried a large number of options, my guess is that this does not work.
    My system: Windows 7 64bit, Unity 2019.1.5f1 (64-bit)
    How can I tell the developers about this problem if there is silence on the forum for answers?
     
  8. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    But what error does UWR give you?
     
  9. btckey

    btckey

    Joined:
    Nov 1, 2012
    Posts:
    40
    In Unity 2019.1.5f1 (64-bit) there are no errors, but UnityWebRequest does not work as it should.
    I installed Unity 2018.2.21f1 (64-bit) and everything is fine, no errors
    My decision to collect the project on Unity 2018.2.21f1 (64-bit)
     
  10. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Sounds like an issue with asset bundle itself. That is, the download succeeds, but loading the bundle does not.
     
  11. btckey

    btckey

    Joined:
    Nov 1, 2012
    Posts:
    40
    Yes that's right