private List <Item> GetItems() { DirectoryInfo directoryInfo = new DirectoryInfo(MyWebRequest.current.LOCAL_ASSET_PATH); float size = 0f; foreach (FileInfo fi in directoryInfo.GetFiles()) { size += fi.Length; } foreach (DirectoryInfo di in directoryInfo.GetDirectories()) { foreach (FileInfo fi in di.GetFiles()) { Debug.Log(fi.Name); size += fi.Length; } } return(new List <Item>() { new Item() { name = directoryInfo.Name, size = FormatterUtil.GetSizeString(size) } }); }
/// <summary> /// 下载网络资源并缓存至本地 /// </summary> IEnumerator IDownAssetBundle(List <Model> datas, Action <int> action) { Debug.Log("下载资源数目:" + datas.Count); float amount = 0f; PanelLoading.current.WebLoading(); foreach (Model data in datas) { string url = WebUtil.HOST + "fileServer/download/" + data.FileUrlMac; #if UNITY_STANDALONE_OSX url = WebUtil.HOST + "fileServer/download/" + data.FileUrlMac; #elif UNITY_STANDLONE_WIN url = WebUtil.HOST + "fileServer/download/" + data.FileUrlWindows; #endif Debug.Log(url); UnityWebRequest webRequest = UnityWebRequest.Get(url); webRequest.SendWebRequest(); ulong downloadedSize = 0; string speed = "0.00b"; float time = 0f; while (!webRequest.isDone) { time += Time.deltaTime; if (time >= 1) { speed = FormatterUtil.GetSizeString((webRequest.downloadedBytes - downloadedSize) / time); downloadedSize = webRequest.downloadedBytes; time = 0f; } string str = string.Format("下载网络资源{0}%,正在下载:{1},速度:{2}/s", (int)((amount + webRequest.downloadProgress) / datas.Count * 100), data.Name, speed); PanelLoading.current.Progress(amount + webRequest.downloadProgress, datas.Count, str); yield return(1); } if (webRequest.isHttpError || webRequest.isNetworkError) { Debug.Log(webRequest.error); PanelLoading.current.Error(webRequest.error); break; } else { amount += 1; //保存ab包到本地 string directoryPath = LOCAL_ASSET_PATH + data.ModelTypeId; if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } string filePath = directoryPath + '/' + data.Id; Debug.Log((File.Exists(filePath) ? "覆盖:" : "新建:") + filePath); File.Create(filePath).Dispose(); File.WriteAllBytes(filePath, webRequest.downloadHandler.data); } } action((int)amount); }
private static Statement TimestampParse(ParserArgument args) { var m = Regex.Match(args.Text, $@"^TIME\s+{Formats.RegisterEx}$", RegexOptions.IgnoreCase); if (m.Success) { return(new TimeStamp(FormatterUtil.GetRegEx(m.Groups[1].Value))); } return(null); }
public Statement Parse(ParserArgument args) { var m = Regex.Match(args.Text, $@"^{Formats.RegisterEx}\s*\{_meta.Operator}\s*{(_meta.OnlyInstant ? Formats.Instant : Formats.ValueEx)}$", RegexOptions.IgnoreCase); if (m.Success) { return(Activator.CreateInstance(_meta.StatementType, FormatterUtil.GetRegEx(m.Groups[1].Value, true), args.Formatter.GetValueEx(m.Groups[2].Value)) as Statement); } return(null); }
public Statement Parse(ParserArgument args) { var m = Regex.Match(args.Text, $@"^{_meta.KeyWord}\s+{Formats.Register}$", RegexOptions.IgnoreCase); if (m.Success) { return(Activator.CreateInstance(_meta.StatementType, FormatterUtil.GetRegEx(m.Groups[1].Value, _lhs)) as Statement); } return(null); }
private static Statement MovParse(ParserArgument args) { var m = Regex.Match(args.Text, $@"^{Formats.RegisterEx}\s*=\s*{Formats.ValueEx}$", RegexOptions.IgnoreCase); if (m.Success) { return(new Mov(FormatterUtil.GetRegEx(m.Groups[1].Value, true), args.Formatter.GetValueEx(m.Groups[2].Value))); } return(null); }
private static Statement PrintParse(ParserArgument args) { if (args.Text.Equals("print", StringComparison.OrdinalIgnoreCase)) { return(new Print(Array.Empty <Content>(), false)); } var m = Regex.Match(args.Text, @"^print\s+(.*)$", RegexOptions.IgnoreCase); if (m.Success) { var strs = m.Groups[1].Value.Split('&'); var contents = new List <Content>(); var cancellinebreak = false; for (int i = 0; i < strs.Length; i++) { var s = strs[i].Trim(); if (i == strs.Length - 1 && s == "\\") { contents.Add(new TextContent("", "\\")); cancellinebreak = true; continue; } if (s.Length == 0 && strs.Length > 1) { contents.Add(new TextContent(" ", "")); continue; } m = Regex.Match(s, Formats.RegisterEx_F); if (m.Success) { contents.Add(new RegContent(FormatterUtil.GetRegEx(s))); continue; } m = Regex.Match(s, Formats.Constant_F); if (m.Success) { var v = args.Formatter.GetConstant(s); contents.Add(new TextContent(v.Val.ToString(), s)); continue; } contents.Add(new TextContent(s)); } return(new Print(contents.ToArray(), cancellinebreak)); } return(null); }
Statement?IStatementParser.Parse(ParserArgument args) { if (args.Text.Equals("for", StringComparison.OrdinalIgnoreCase)) { return(new For_Infinite()); } var m = Regex.Match(args.Text, $@"^for\s+{Formats.ValueEx}$", RegexOptions.IgnoreCase); if (m.Success) { return(new For_Static(args.Formatter.GetValueEx(m.Groups[1].Value))); } m = Regex.Match(args.Text, $@"^for\s+{Formats.RegisterEx}\s*=\s*{Formats.ValueEx}\s*to\s*{Formats.ValueEx}$", RegexOptions.IgnoreCase); if (m.Success) { return(new For_Full(FormatterUtil.GetRegEx(m.Groups[1].Value, true), args.Formatter.GetValueEx(m.Groups[2].Value), args.Formatter.GetValueEx(m.Groups[3].Value))); } // next return(NextParse(args)); }