Search Unity

TextAsset not found in AssetBundleLoadAssetOperation

Discussion in 'Asset Bundles' started by philmzo, Nov 19, 2016.

  1. philmzo

    philmzo

    Joined:
    Dec 2, 2015
    Posts:
    7
    Hi,

    I can't get the TextAsset with this code on Unity 5.4.0f3-Windows10:
    Code (CSharp):
    1.  AssetBundleLoadAssetOperation msg = AssetBundleManager.LoadAssetAsync(assetBundleName, "ClassLibrary1.bytes", typeof(TextAsset));
    2.  
    3.         if (msg == null)
    4.         {
    5.             print("no");
    6.             yield break;
    7.         } else {
    8.            print("yes");
    9.            }
    10.         yield return StartCoroutine(msg);
    11.  
    12.  
    13.         TextAsset txt = msg.GetAsset<TextAsset>();
    14.         // Load the assembly and get a type (class) from it
    15.         print(txt);
    16.         var assembly = System.Reflection.Assembly.Load(txt.bytes);
    yes is printed but print(txt) throws null then of course I don't get assembly:
    Object reference not set to an instance of an object
    LoadAssets+<InstantiateGameObjectAsync>c__Iterator3.MoveNext ()

    I double checked the Asset manifest and ClassLibrary1.bytes is present (hence the "yes" print).
    And it's compiled with .Net 3.5.
    Any idea?
    Thanks