Example #1
0
        protected override async Task AsyncRun()
        {
            string fullurl;
            var    loc = PathRouter.GetFullPath(Url, true, out fullurl);

            if (loc == PathLocation.NotFound)
            {
                throw new FileNotFoundException("BytesLoader", Url);
            }

            ResLog.VerboseFormat("BytesLoader.Load, loc:{0}, fullpath:{1}", loc, fullurl);

            byte[] bytes = null;
            try
            {
                bytes = await WWWLoader.AsyncLoad(fullurl, v => Progress = v);

                Finish(bytes);
            }
            catch (Exception e)
            {
                Finish(null, true);
                throw e;
            }
        }
Example #2
0
        static string GetLoadUrl(string url)
        {
            url = PathRouter.ABFolder + '/' + url;
            string fullurl;
            var    loc = PathRouter.GetFullPath(url, true, out fullurl);

            if (loc == PathLocation.NotFound)
            {
                throw new FileNotFoundException("AssetBundleLoader", url);
            }

            if (fullurl.StartsWith(PathRouter.FileProtocol))
            {
                fullurl = fullurl.Substring(PathRouter.FileProtocol.Length);
            }
            return(fullurl);
        }
Example #3
0
        public static byte[] Load(string path)
        {
            using (var timer = LoadTimer.Start <BytesLoader>(path))
            {
                string fullpath;
                var    loc = PathRouter.GetFullPath(path, false, out fullpath);
                if (loc == PathLocation.NotFound)
                {
                    throw new FileNotFoundException("BytesLoader", path);
                }

                ResLog.VerboseFormat("BytesLoader.Load, loc:{0}, fullpath:{1}", loc, fullpath);

                if (loc == PathLocation.InApp && Application.platform == RuntimePlatform.Android)
                {
                    return(AndroidPlugin.GetAssetBytes(path));
                }
                else
                {
                    return(File.ReadAllBytes(fullpath));
                }
            }
        }