private void Awake() { if (_cmCurve == null) { GameObject go = GameObject.Find(ConfigFilename); if (go == null) { #if UNITY_EDITOR go = (GameObject)Resources.Load(ConfigFilename).ExtInstantiate(); #else ResObj resource = ResService.GetResource(ConfigFilename); if (resource != null) { go = (GameObject)resource.Content.ExtInstantiate(); ResService.UnloadResource(resource); } #endif if (null != go) { ExtObject.ExtDontDestroyOnLoad(go); } } if (go != null) { go.name = ConfigFilename; _cmCurve = go.ExtGetComponent <UICurveCfg>(); _cmAudio = go.ExtGetComponent <UIAudioCfg>(); } } _cacheTf = transform; _originalScale = _cacheTf.localScale; }
public bool CancelLoadAsset(ResObj resObj) { AsyncLoadResTask task = null; if (loadingAssetTaskDic.TryGetValue(resObj.CRC, out task)) { for (int i = task.FinishActionList.Count; i >= 0; --i) { var action = task.FinishActionList[i]; if (action != null && task.Param is ResObj && task.Param == resObj) { action.Reset(); asyncFinishActionPool.Recycle(action); task.FinishActionList.Remove(action); } } if (task.FinishActionList.Count == 0) { loadingAssetTaskDic.Remove(resObj.CRC); loadingAssetTaskList[(int)task.Priority].Remove(task); task.Reset(); asyncLoadTaskPool.Recycle(task); } return(true); } return(false); }
//回调Lua public void OnLoadAssetCompleted(string assetName, int result, ResObj resource) { if (_onLoadAssetCompleted != null) { _onLoadAssetCompleted(assetName, result, resource); } }
public byte[] CustomLuaLoader(ref string filepath) { filepath = filepath.Replace('.', '/'); filepath = "LuaScripts/" + filepath + ".lua"; //编辑器 强制走 #if UNITY_EDITOR && !USE_PACK_RES string fullPath = JW.Res.FileUtil.CombinePath(Application.dataPath, "Resources/" + filepath); return(JW.Res.FileUtil.ReadFile(fullPath)); #else ResObj res = ResService.GetResource(filepath); if (res != null && res.Content != null) { BinaryObject binaryObject = res.Content as BinaryObject; byte[] bb = binaryObject.m_data; ResService.UnloadResource(res, false); return(bb); } else { // 有脚本加载失 JW.Common.Log.LogE("Load lua script failed, path:{0}.", filepath); return(null); } #endif }
public void ReleaseObj(GameObject obj, int maxCacheCount = -1, bool isDestroyCache = false, bool isRecyleParent = false) { var insID = obj.GetInstanceID(); ResObj resObj = null; if (resObjDic.TryGetValue(insID, out resObj)) { Debug.LogWarningFormat("{0} obj is not created by ObjMgr", obj.name); return; } if (resObj.IsCachePool) { Debug.LogWarningFormat("{0} obj recyled to cache pool", obj.name); return; } #if UNITY_EDITOR obj.name += "(Recycle)"; #endif if (maxCacheCount == 0) { resObjDic.Remove(insID); ResSvc.Ins.ReleaseRes(resObj.CRC, false); resObj.Reset(); resObjPool.Recycle(resObj); } else { List <ResObj> list = null; if (!objCachePoolDic.TryGetValue(resObj.CRC, out list)) { list = new List <ResObj>(); objCachePoolDic.Add(resObj.CRC, list); } if (recyleRoot) { resObj.CloneObj.transform.SetParent(recyleRoot); } else { resObj.CloneObj.SetActive(false); } if (maxCacheCount < 0 || list.Count < maxCacheCount) { list.Add(resObj); resObj.IsCachePool = true; //ResSvc.Ins.DecreaseResRef(resObj.CRC); } else { resObjDic.Remove(insID); ResSvc.Ins.ReleaseRes(resObj.CRC, false); resObj.Reset(); resObjPool.Recycle(resObj); } } }
public ActionResult Default(string title, int?icon) { if (string.IsNullOrEmpty(title)) { title = "Msg"; } return(Content(ResObj.LayerMsg(title, icon, Utils.GetPostUrlInfo()))); }
/// <summary> /// 返回错误消息 /// </summary> /// <param name="msg">消息</param> /// <param name="url">跳转链接</param> /// <param name="isEval">是否需要eval执行</param> /// <returns></returns> public ActionResult Success(string msg, string url = "Index", bool isEval = true) { url = Utils.GetActionUrl(url); if (isEval) { return(Content(ResObj.LayerScript(msg, Icon.Success, url))); } return(Content(ResObj.LayerMsg(msg, Icon.Success, url))); }
public void CancelCreatIns(long guid) { ResObj resObj = null; if (createingResObjs.TryGetValue(guid, out resObj) && ResSvc.Ins.CancelLoadAsset(resObj)) { createingResObjs.Remove(guid); resObj.Reset(); resObjPool.Recycle(resObj); } }
/// <summary> /// 添加缓存 /// </summary> /// <param name="data">资产数据</param> /// <param name="resource">资源</param> /// <returns>添加到缓存的资产(null标识添加失败)</returns> public BaseAsset AddCache(AssetData data, ResObj resource) { BaseAsset ba = CreateAsset(data, resource); if (ba == null) { return(null); } _cache.AddAsset(ba); return(ba); }
public ActionResult Index(Lang model) { if (bll_Lang.Exists(c => c.msgid == model.msgid)) { return(Content(ResObj.LayerMsg("请勿重复添加!", Icon.Error))); } model.msgstr = model.msgid; bll_Lang.AddEntity(model); return(Content(ResObj.LayerMsg("添加成功!", Icon.Success))); }
public ActionResult Edit(Lang model) { if (bll_Lang.Exists(c => c.msgid == model.msgid)) { return(Content(ResObj.LayerMsg("请勿重复添加!", Icon.Error, indexUrl))); } model.msgstr = model.msgid; bll_Lang.EditEntity(model); return(Content(ResObj.LayerMsg("修改成功!", Icon.Success, indexUrl))); }
public ActionResult Index(int type) { if (type > 0) { GetCode(type); } else { var list = _DataItemService.LoadEntities(c => true).ToList(); foreach (var item in list) { GetCode(item.Id); } } return(Content(ResObj.LayerScript("执行成功!", Icon.Success))); }
/// 获取文件内容 public static string GetTextFromFile(string filename) { string text = string.Empty; ResObj res = ResService.GetResource(filename); if (res != null) { BinaryObject binaryObject = res.Content as BinaryObject; byte[] rawBytes = binaryObject.m_data; if (rawBytes != null && rawBytes.Length > 0) { ResService.UnloadResource(res); text = Encoding.UTF8.GetString(rawBytes); } } return(text); }
/// <summary> /// 返回计算结果 /// </summary> /// <param name="str"></param> public void ResWrite(string str) { try { Icon i = Icon.Success; if (string.IsNullOrEmpty(str)) { str = "请输入正确的数据!"; i = Icon.Error; } ResObj res = new ResObj("返回结果", str, i); Response.Write(Utils.ObjectToJson(res)); } catch (Exception e) { ResObj res = new ResObj("错误信息", e.StackTrace + "报错," + e.Message, Icon.Error); Response.Write(Utils.ObjectToJson(res)); } }
//------------------------------------------ /// <summary> /// 取资源二进制数据 /// </summary> /// <param name="resPath">资源路径</param> /// <returns>二进制数据</returns> public static byte[] GetResourceBytes(string resPath) { ResObj res = ResService.GetResource(resPath); if (res == null) { return(null); } BinaryObject binaryObject = res.Content as BinaryObject; if (binaryObject == null) { return(null); } byte[] rawBytes = binaryObject.m_data; ResService.UnloadResource(res); return(rawBytes); }
private void Awake() { if (ApplyButtonClickCurve) { GameObject go = GameObject.Find(ConfigFilename); if (go == null) { #if UNITY_EDITOR go = (GameObject)Resources.Load(ConfigFilename).ExtInstantiate(); #else ResObj resource = ResService.GetResource(ConfigFilename); if (resource != null) { go = (GameObject)resource.Content.ExtInstantiate(); ResService.UnloadResource(resource); } #endif if (null != go) { ExtObject.ExtDontDestroyOnLoad(go); } } if (go != null) { go.name = ConfigFilename; UICurveCfg cfg = go.ExtGetComponent <UICurveCfg>(); _curve = cfg.GetCurve("Normal"); } } // if (_curve != null) { Keyframe lastKf = _curve[_curve.length - 1]; _lastKeyTime = lastKf.time; } _cacheTf = transform; _originalScale = _cacheTf.localScale; }
/// <summary> /// 判断是否为回文 /// </summary> /// <param name="input">待判断字符串</param> public void IsPalindrome(string input) { Stack <char> stack = new Stack <char>(); string msg = ""; Icon icon = Icon.Success; // 字符串的一半入栈 for (int i = 0; i < input.Length / 2; i++) { stack.Push(input[i]); } // 字符串最后一个值的索引 int index = input.Length - 1; // 依次出栈 while (stack.Count > 0) { // 若有不同的字符,结束出栈 if (input[index--] != stack.Pop()) { break; } } // 若index的大小不是字符串长度的一半 if (index != input.Length / 2) { msg = input + ",不是回文!"; icon = Icon.Error; } else { msg = input + ",是回文!"; } ResObj res = new ResObj("返回结果", msg, icon); Response.Write(Utils.ObjectToJson(res)); }
private BaseAsset CreateAsset(AssetData data, ResObj resource) { if (resource == null || resource.Content == null) { JW.Common.Log.LogE("AssetManager.CreateAsset : invalid parameter - {0}", data.Name); return(null); } data.Callback = null; BaseAsset ba = data.Factory.CreateObject(); if (ba == null) { JW.Common.Log.LogE("AssetManager.CreateAsset : failed to create asset - {0}", data.Name); return(null); } ba.BaseData = data; ba.Resource = resource; if (!AssetProcessor.ProcessCreate(ba)) { JW.Common.Log.LogE("AssetManager.CreateAsset : failed to process create - {0}", data.Name); ba.BaseData.Callback = null; ba.BaseData.Factory = null; ba.Resource = null; data.Factory.DestroyObject(ba); return(null); } //AssetProcessor.ProcessAssociateResource(ba); return(ba); }
/// <summary> /// 翻译 /// </summary> /// <param name="path">语言包路径</param> /// <param name="url">翻译网址</param> /// <param name="Lan">翻译类型</param> public ActionResult Translate(string path, string url, string Lan) { string content = FileAction.ReadToStr(path); Dictionary <string, string> dic = new Dictionary <string, string>(); string reg = "msgid \"(?<msgid>.*)\"\r\nmsgstr \"(?<msgstr>.*)\""; string[] strArr = DataCheck.GetRegStrArr(content, reg); foreach (var str in strArr) { MatchCollection res = Regex.Matches(str, reg, RegexOptions.IgnoreCase); foreach (Match item in res) { dic.Add(item.Groups["msgid"].Value, item.Groups["msgstr"].Value); } } SaveLanJs(dic); // 发送翻译请求 // Dictionary<string, string> dicRes= BaiduTranslate(dic, Lan, ""); return(Content(ResObj.LayerMsg("转换成功!", Icon.Success, "Index"))); }
/// <summary> /// 装载 /// </summary> /// <param name="data">资产数据</param> /// <param name="clone">是否Clone一个副本</param> /// <returns>资产</returns> public BaseAsset Load(ref AssetData data, bool clone) { if (string.IsNullOrEmpty(data.Filename)) { JW.Common.Log.LogE("AssetManager.Load : invalid parameter"); return(null); } //缓存找 BaseAsset ba = _cache.GetAsset(data.Name); if (ba != null) { //缓存复制 if (clone) { BaseAsset cloneBa = AssetProcessor.ProcessClone(ba); _cache.AddAsset(ba); ba = cloneBa; } if (ba != null) { if (!AssetProcessor.ProcessCreate(ba)) { JW.Common.Log.LogE("AssetManager.CreateAsset : failed to process create - {0}", data.Name); ba.BaseData.Callback = null; ba.BaseData.Factory = null; ba.Resource = null; data.Factory.DestroyObject(ba); return(null); } _usingAsset.Add(ba); } return(ba); } //没在缓存 同步创建 ResObj resource = ResService.GetResource(data.Filename); if (resource == null) { JW.Common.Log.LogE("AssetManager.Load : failed to load resource - {0}", data.Filename); return(null); } if (resource.Content == null) { JW.Common.Log.LogE("AssetManager.Load : failed to load resource - {0}", data.Filename); ResService.UnloadResource(resource); return(null); } ba = CreateAsset(data, resource); if (ba == null) { ResService.UnloadResource(resource); return(null); } if (clone) { BaseAsset cloneBa = AssetProcessor.ProcessClone(ba); _cache.AddAsset(ba); ba = cloneBa; } if (ba != null) { _usingAsset.Add(ba); } return(ba); }
public MainWindow() { InitializeComponent(); color1.ColorChange += delegate { // 不要通过XAML来绑定颜色,无法获取到通知 BorderBrush = color1.CurrentColor.OpaqueSolidColorBrush; }; ts.IsChecked = true; exit.Click += delegate { Close(); }; treeView.SizeChanged += delegate { waterfallFlow.Refresh(); }; rt1.Clear(); rt1.AddLine("阅读模式"); rt1.AddLine(); rt1.AddLine("添加正常内容"); rt1.AddLine("添加正常内容可点击", delegate { MessageBox.Show("你点击了我!"); }); rt1.AddLine("添加自定义颜色内容", new RgbaColor(255, 0, 0, 255)); rt1.AddLine("添加自定义颜色内容可点击", new RgbaColor(255, 0, 0, 255), delegate { MessageBox.Show("你点击了我!"); }); rt3.Clear(); rt3.AddLine("内容追加测试(不换行添加)"); rt3.AddLine("http://www.baidu.com", "http://www.baidu.com"); rt3.AddLine("中间的间距是Add(\" \");方法添加的两个空格"); rt3.AddLine(); rt3.AddLine("追加正常内容"); rt3.AddLine(); rt3.Add("正常1"); rt3.Add(" "); rt3.Add("正常2"); rt3.Add(" "); rt3.Add("正常3"); rt3.AddLine(); rt3.AddLine("追加正常内容可点击"); rt3.AddLine(); rt3.Add("正常1", delegate { MessageBox.Show("你点击了我!"); }); rt3.Add(" "); rt3.Add("正常2", delegate { MessageBox.Show("你点击了我!"); }); rt3.Add(" "); rt3.Add("正常3", delegate { MessageBox.Show("你点击了我!"); }); rt3.AddLine(); rt3.AddLine("追加自定义颜色内容"); rt3.AddLine(); rt3.Add("颜色1", new RgbaColor(255, 0, 0, 255)); rt3.Add(" "); rt3.Add("颜色2", new RgbaColor(0, 255, 0, 255)); rt3.Add(" "); rt3.Add("颜色3", new RgbaColor(0, 0, 255, 255)); rt3.AddLine(); rt3.AddLine("追加自定义颜色内容可点击"); rt3.AddLine(); rt3.Add("颜色1", new RgbaColor(255, 0, 0, 255), delegate { MessageBox.Show("你点击了我!"); }); rt3.Add(" "); rt3.Add("颜色2", new RgbaColor(0, 255, 0, 255), delegate { MessageBox.Show("你点击了我!"); }); rt3.Add(" "); rt3.Add("颜色3", new RgbaColor(0, 0, 255, 255), delegate { MessageBox.Show("你点击了我!"); }); rt3.AddLine(); DispatcherTimer timer = new DispatcherTimer(); timer.Tick += delegate { pb1.Value = pb1.Value + 1 > pb1.Maximum ? 0 : pb1.Value + 1; pb2.Value = pb2.Value + 1 > pb2.Maximum ? 0 : pb2.Value + 1; pb2.Title = pb2.Hint; pb2.Hint = null; }; timer.Interval = new TimeSpan(0, 0, 0, 0, 20); timer.Start(); ContentRendered += delegate { // 手动加载指定HTML web1.Document = ResObj.GetString(Assembly.GetExecutingAssembly(), "Resources.about.html"); // 导航到指定网页 web2.Source = new Uri("http://ie.icoa.cn/"); }; foreach (FrameworkElement fe in lists.Children) { if (fe is MetroExpander) { (fe as MetroExpander).Click += delegate(object sender, EventArgs e) { if ((fe as MetroExpander).CanHide) { foreach (FrameworkElement fe1 in lists.Children) { if (fe1 is MetroExpander && fe1 != sender) { (fe1 as MetroExpander).IsExpanded = false; } } } }; } } /* * // Chrome 浏览器封装 * ChromeBrowser chrome = new ChromeBrowser(); * chromeGrid.Children.Add(chrome); * chromeText.Text = chrome.Address; * chromeText.ButtonClick += delegate { chrome.Load(chromeText.Text); }; * chromeText.KeyUp += delegate (object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { chrome.Load(chromeText.Text); } }; * chrome.Load("http://ie.icoa.cn/"); */ }
public ActionResult Delete(int id) { bll_Lang.DeleteEntity(id); return(Content(ResObj.LayerMsg("删除成功!", Icon.Success, indexUrl))); }