Search Unity

AssetBundle Material Problem - WebGL

Discussion in 'Asset Bundles' started by AlbyDj90, Mar 6, 2019.

  1. AlbyDj90

    AlbyDj90

    Joined:
    Feb 7, 2015
    Posts:
    35
    I have a problem with AssetBundle.
    I'm testing the use of AssetBundle in a WebGL app.
    I found several "strange" things that I do not think have ever happened in my Windows programs.
    In my test I created a Cube with a standard gray material that is automatically included in the AB. I create AB for WebGL (no compression).
    Download the AB ... and there is no more material inside.
    IF, however, I attach the material manually to that AB it is present inside once downloaded but if I try to instantiate the cube and then assign that material .... it is not there! Purple Cube.
    But there is a strange thing that has sent me the brain in jelly. To check if the material existed or not I did this:

    -------------------------------------------------- ---------------------------

    var material = bundle.LoadAsset ("materialdelfault");
    Material mat = material as Material;
    print (mat.name);
    object.GetComponent <MeshRenderer> (). material = mat;

    -------------------------------------------------- ---------------------------

    So doing the material ..... it works and is assigned. ._.
    But I get a NullReferenceException error exactly at the print line. What the hell is going on?
    Thanks for any help

    EDIT: i tried to put a texture with a material in a Separate AB and when i download the texture is missing completly from the AB.
     
  2. AlbyDj90

    AlbyDj90

    Joined:
    Feb 7, 2015
    Posts:
    35
    I managed to make the program work in the editor. The problem was an incorrect use of AssetBundle.Unload (FALSE) instead of AssetBundle.Unload (TRUE).
    In any case, once loaded online, the program returns an error as soon as I try to instantiate a cube:
    Uncaught RuntimeError: memory access out of bounds.
    I have found many people with the same problem but not a real solution ... what could be the cause?
     
  3. AlbyDj90

    AlbyDj90

    Joined:
    Feb 7, 2015
    Posts:
    35
    The problem, in my case, was the use of a cube from the Unity primitive. With a material or an FBX made with a 3D model program i have no problem with the WebGL or any other program that use AssetBundle. Is this a known problem?