Skip to content

从assetbundle加载代码 ( loading code from asset bundles )

xebecnan edited this page Nov 3, 2013 · 1 revision
// -- sample code for loading binary Asset Bundles --------------------
String s = "file:///"+Application.streamingAssetsPath+"/testx.unity3d";
WWW www = new WWW(s);
yield return www;
if(www.assetBundle.mainAsset != null) {
    TextAsset cc = (TextAsset)www.assetBundle.mainAsset;
    var status = Lua.L_LoadBytes(cc.bytes, "test");
    if( status != ThreadStatus.LUA_OK )
    {
        throw new Exception( Lua.ToString(-1) );
    }
    status = Lua.PCall( 0, 0, 0);
    if( status != ThreadStatus.LUA_OK )
    {
        throw new Exception( Lua.ToString(-1) );
    }
    Debug.Log("---- call done ----");
}