Exemplo n.º 1
0
 private bool loadError(FileStream fs, StreamReader sr, string errormsg)
 {
     sr.Close();
     fs.Close();
     BugReport.Report(errormsg);
     return(false);
 }
Exemplo n.º 2
0
        public bool Load(string res, AssetLoadedCallback callback)
        {
            res = fullResPath(res);
            AssetBundleInfo abInfo = _cfg.GetAssetBundle(res);

            if (abInfo == null)
            {
                BugReport.Report("ResLoader::Load not find res:" + res);
                return(false);
            }

            bool isimmediate = (abInfo.flag & LoadABFlag.IMMEDIATE) == LoadABFlag.IMMEDIATE;
            bool isfixed     = (abInfo.flag & LoadABFlag.FIXED) == LoadABFlag.FIXED;

            if (isimmediate)
            {
                AssetBundle ab = immediateLoadAssetBundle(abInfo);
                callback(ab.LoadAsset(res));
            }
            else
            {
                preImmediateLoadDependAssetBundle(abInfo);
                AssetBundleManager.loadAssetBundle(ResConfig.assetBundleUrlBasePath + abInfo.assetbundlename, abInfo.version, isfixed, (AssetBundle ab) => {
                    callback(ab.LoadAsset(res));
                });
            }

            return(true);
        }
Exemplo n.º 3
0
        private int safeToInt(string sval)
        {
            int val;

            if (!int.TryParse(sval, out val))
            {
                BugReport.Report("AssetConfigLoader::safeToInt convert sval:" + sval + " failed!");
                return(0);
            }
            return(val);
        }
Exemplo n.º 4
0
        private int readIntValueByKey(string segment, string key)
        {
            string keywithtoken = key + ":";
            int    pos          = segment.IndexOf(keywithtoken);

            if (pos < 0)
            {
                BugReport.Report("AssetConfigLoader::readIntValueByKey read key:" + key + " from segment:" + segment + " failed!");
                return(0);
            }
            return(safeToInt(segment.Substring(pos + keywithtoken.Length)));
        }
Exemplo n.º 5
0
        public byte[] immediateLoad(string res)
        {
            string          fullresname = fullResPath(res);
            AssetBundleInfo abInfo      = _cfg.GetAssetBundle(fullresname);

            if (abInfo == null)
            {
                BugReport.Report("ResLoader::immediateLoad not find res:" + fullresname);
                return(null);
            }

            AssetBundle ab        = immediateLoadAssetBundle(abInfo);
            Object      asset     = ab.LoadAsset(fullresname);
            TextAsset   textAsset = (TextAsset)asset;

            return(textAsset.bytes);
        }
Exemplo n.º 6
0
        public bool EvalFile_byteCode(byte[] src)
        {
            IntPtr ctx = _context.ptr;

            Native.uts_push_lstring_d(ctx, src, src.Length);
            Native.duk_to_buffer_u(ctx, -1);
            Native.duk_load_function(ctx);
            int rt = Native.duk_pcall(ctx, 0);

            if (rt != 0)
            {
                BugReport.Report("Error: " + Native.duk_safe_to_string(ctx, -1));
            }

            Native.duk_pop(ctx); // pop result or error

            return(rt == 0);
        }
Exemplo n.º 7
0
            static private int inner_modSearch_byteCode(IntPtr ctx, byte[] src)
            {
                Native.uts_push_lstring_d(ctx, src, src.Length);
                Native.duk_to_buffer_u(ctx, -1);
                Native.duk_load_function(ctx);

                pushModSearchArgs(ctx);
                setModSearchArgs(ctx);

                if (Native.duk_pcall(ctx, 0) != 0)
                {
                    BugReport.Report("Error: " + Native.duk_safe_to_string(ctx, -1));
                }

                Native.duk_pop(ctx); // pop result or error
                popModSearchArgs(ctx);
                setModSearchArgs(ctx);

                return(0);
            }
Exemplo n.º 8
0
        private void TsCall()
        {
            IntPtr ctx = _context.ptr;

            Native.duv_push_ref(ctx, _funref);
            if (Native.duk_is_function(ctx, -1) != 1)
            {
                Native.duk_pop(ctx);
                return;
            }

            FillCallArgs(ctx);

            if (Native.duk_pcall(ctx, _args.Length) != 0)
            {
                BugReport.Report("Error: " + Native.duk_safe_to_string(ctx, -1));
                Native.duk_pop(ctx); // pop error
                return;
            }

            Native.duk_pop(ctx); // pop result
            return;
        }