[MenuItem(CZMToolConst.Menu_Root + "GroupGameObjects/Group打包(解除Group) %&g")] //crtl+alt+g public static void GroupGameObject_DisGroup() { Object[] selectedObjects = Selection.objects; GameObject groupGameObject = selectedObjects[0] as GameObject; List <Transform> childrenTransformList = new List <Transform>(); for (int i = 0; i < groupGameObject.transform.childCount; i++) { childrenTransformList.Add(groupGameObject.transform.GetChild(i)); } Vector3 min = Vector3Const.Max; Vector3 max = Vector3Const.Min; GetMinMax(groupGameObject.transform, ref min, ref max); if (max == Vector3Const.Max) { LogCat.error("没有Meshes"); return; } groupGameObject.transform.DetachChildren(); groupGameObject.transform.position = (min + max) / 2; foreach (Transform transform in childrenTransformList) { transform.parent = groupGameObject.transform; } LogCat.log("GroupGameObjects finished"); }
[AOP_Test("chen")] //AOP属性 用于AOP处理 public void CallHello(string message, Shape2D shape) { using (new AOP(this, message, shape)) //对AOP的属性处理的调用,xxx,yyy,kkk为该函数的参数 { LogCat.LogError(message); } }
/// <summary> /// Send a message to the given players client console. /// </summary> /// <param name="player"></param> /// <param name="category"></param> /// <param name="text"></param> /// <param name="args"></param> public static void ClientConsoleOutput(Client player, LogCat category, string text, params object[] args) { var textFormat = string.Format(text, args); var format = ConsoleHandler.LogCatToString(category); API.shared.triggerClientEvent(player, "console_client_server_msg_output", format.Prefix, textFormat, format.Color); }
public static void Output(string str, LogCat category = LogCat.Info) { lock (_consolelock) { if (category == LogCat.Info) { Console.ForegroundColor = ConsoleColor.Gray; } else if (category == LogCat.Warn) { Console.ForegroundColor = ConsoleColor.Yellow; } else if (category == LogCat.Error) { Console.ForegroundColor = ConsoleColor.Red; } else if (category == LogCat.Debug) { Console.ForegroundColor = ConsoleColor.DarkGray; } Console.WriteLine("[" + DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss") + "] " + str); } if (_log) { lock (_filelock) { File.AppendAllText("server.log", "[" + DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss") + "] " + str + Environment.NewLine); } } }
// 穿上装备 public bool PutOnEquip(Item equip) { var env = equip.GetEnv(); if (env != null) { LogCat.error(string.Format("PutOnEquip error:{0} still in {1}", equip, env)); return(false); } var list = this.oEquips.GetEquips_ToEdit(); if (list.Contains(equip)) { LogCat.error(string.Format("PutOnEquip error:{0} already put on {1}", this, equip)); return(false); } if (!(this.OnPutOnEquip(equip) && equip.OnPutOnEquip(this))) { return(false); } equip.SetEnv(this); equip.SetIsPutOn(true); list.Add(equip); return(true); }
public static async Task LogEx(string message, Exception exception, LogCat cat = LogCat.Default) { try { _logPath = _logPath ?? Path.Combine(SettingsManager.RootDirectory, "logs"); var file = Path.Combine(_logPath, $"{cat}.log"); if (!Directory.Exists(_logPath)) { Directory.CreateDirectory(_logPath); } var cc = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; await File.AppendAllTextAsync(file, $"{DateTime.Now,-19} [{LogSeverity.Critical,8}]: {message} {Environment.NewLine}{exception}{exception.InnerException}{Environment.NewLine}").ConfigureAwait(false); Console.WriteLine($"{DateTime.Now,-19} [{LogSeverity.Critical,8}] [{cat}]: {message}"); Console.ForegroundColor = cc; } catch { // ignored } }
public static void LogErrorFormat(LogCat cat, string format, params object[] args) { #if UNITY_EDITOR WriteLog("E", cat, string.Format(format, args)); #endif Debug.LogError(Format(cat, format, args)); }
public bool AddRole(Role role) { var env = role.GetEnv(); if (env != null) { LogCat.error(string.Format("{0} still in {1}", role, env)); return(false); } var list = this.oRoles.GetRoles_ToEdit(); if (list.Contains(role)) { LogCat.error(string.Format("{0} already has role:{1}", this, role)); return(false); } if (!(this.OnAddRole(role) && role.OnAddRole(this))) { return(false); } role.SetEnv(this); list.Add(role); return(true); }
//镶入镶物 public bool EmbedOn(Item embed) { var env = embed.GetEnv(); if (env != null) { LogCat.error(string.Format("{0} still in {1}", embed, env)); return(false); } var list = this.oEmbeds.GetEmbeds_ToEdit(); if (list.Contains(embed)) { LogCat.error(string.Format("{0} already embed on {1}", this, embed)); return(false); } if (!(this.OnEmbedOn(embed) && embed.OnEmbedOn(this))) { return(false); } embed.SetEnv(this); list.Add(embed); return(true); }
[AOP_Test("zhongmou")] //AOP属性 用于AOP处理 public void CallWorld(string message) { using (new AOP(this, message)) //对AOP的属性处理的调用,xxx,yyy,kkk为该函数的参数 { LogCat.LogError(message); } }
internal static MessageFormat LogCatToString(LogCat category) { switch (category) { case LogCat.Info: return(new MessageFormat("~b~INFO", "~w~")); case LogCat.Warn: return(new MessageFormat("~p~WARN", "~p~")); case LogCat.Error: return(new MessageFormat("~y~ERROR", "~y~")); case LogCat.Debug: return(new MessageFormat("~c~DEBUG", "~c~")); case LogCat.Trace: return(new MessageFormat("~c~TRACE", "~c~")); case LogCat.Fatal: return(new MessageFormat("~r~FATAL", "~r~")); default: return(new MessageFormat("~b~INFO", "~w~")); } }
public void Append(string lv, LogCat cat, string log) { lock (mLock) { var s = string.Format("[{0}] [{1}] [{2}] {3}", lv, System.DateTime.Now.ToString("HH:mm:ss.ffff"), cat, log); mLogs.Enqueue(s); } }
public static void Log(LogCat cat, string content) { #if UNITY_EDITOR WriteLog("I", cat, content); #endif if (UseCategory(cat)) { Debug.Log(Format(cat, content)); } }
public static void LogWarningFormat(LogCat cat, string format, params object[] args) { #if UNITY_EDITOR WriteLog("W", cat, string.Format(format, args)); #endif if (UseCategory(cat)) { Debug.LogWarning(Format(cat, format, args)); } }
static void WriteLog(string lv, LogCat cat, string content) { if (sInstance != null && sInstance.mLogWriter != null) { var stack = Environment.StackTrace; var index = stack.LastIndexOf(stackAt); index = stack.IndexOf('\n', index + 1) + 1; sInstance.mLogWriter.Append(lv, cat, StringUtil.Concat(content, '\n', stack.Substring(index), '\n')); } }
public static string AssetsPathToAssetsPackagePath(string assetPath) { int index = assetPath.IndexEndOf(BuildConst.AssetsPackage_Root); if (index != -1) { return(assetPath.Substring(index + 1)); } LogCat.LogError("Asset path is not a package path!"); return(assetPath); }
private void __CounterFunc() { if (this.counter.count < 0) { LogCat.error("counter.count < 0"); } if (this.counter.count == 0 && this.isSpellAnimationFinished && !this.IsDestroyed()) { this.RemoveSelf(); } }
public void OnEnable() { m_messages = new Queue<string>(); m_logCat = new LogCat(); m_lastScrollPos = 1f; InitProcess(); m_textAreaStyle = new GUIStyle(); m_textAreaStyle.normal.background = Texture2D.blackTexture; m_textAreaStyle.normal.textColor = Color.white; m_textAreaStyle.richText = true; m_textAreaStyle.wordWrap = true; }
public bool UseItem(Item item) { var env = item.GetEnv(); if (env != null) { LogCat.error(string.Format("UseItem error:{0} still in {1}", item, env)); return(false); } return(this.OnUseItem(item) && item.OnUseItem(this)); }
[MenuItem(CZMToolConst.Menu_Root + "GroupGameObjects/Group打包(中心) %g")] //crtl+g public static void GroupGameObject_Center() { Object[] selectedObjects = Selection.objects; List <Transform> transformList = new List <Transform>(); foreach (GameObject gameObject1 in selectedObjects) { bool isNeedToAdd = true; foreach (GameObject gameObject2 in selectedObjects) { if (gameObject1.transform.parent == gameObject2.transform) { isNeedToAdd = false; break; } } if (isNeedToAdd) { transformList.Add(gameObject1.transform); } } Vector3 min = Vector3Const.Max; Vector3 max = Vector3Const.Min; foreach (Transform transform in transformList) { GetMinMax(transform, ref min, ref max); } if (max == Vector3Const.Max) { LogCat.error("没有Meshes"); return; } GameObject group = new GameObject(); group.name = "Group"; group.transform.position = (min + max) / 2; foreach (Transform transform in transformList) { transform.parent = group.transform; } LogCat.log("GroupGameObjects finished"); }
public void Append(LogCat cat, string text) { if (Disposing) { return; } switch (cat) { default: case LogCat.All: break; case LogCat.Cache: if (!this.toolStripButtonShowCache.Checked) { return; } break; case LogCat.Perf: if (!this.toolStripButtonShowPerf.Checked) { return; } break; case LogCat.Xform: if (!this.toolStripButtonShowXform.Checked) { return; } break; } int start = this.textBox.SelectionStart; int length = this.textBox.SelectionLength; bool atEnd = start == this.textBox.TextLength; this.textBox.AppendText(text); if (atEnd) { this.textBox.Select(this.textBox.TextLength, 0); } else { this.textBox.Select(start, length); } this.textBox.ScrollToCaret(); }
public static bool Hide(Category category) { if (active.Contains(category)) { active.Remove(category); } if (hidden.Contains(category)) { return(true); } hidden.Add(category); return(hidden.Contains(category)); }
public string ParseString(string expression) { LogCat.log(string.Format("解析ing:{0}", expression)); //决定解析的先后顺序 if (expression.IndexOf("${") != -1) { if (expression.IndexOf("$${") != -1) { expression = expression.ReplaceAll(DoerAttrParserConst.Pattern3, Replace); } expression = expression.ReplaceAll(DoerAttrParserConst.Pattern2, Replace); } return(expression.ReplaceAll(DoerAttrParserConst.Pattern1, Replace)); }
public static bool Show(Category category) { if (hidden.Contains(category)) { hidden.Remove(category); } if (active.Contains(category)) { return(true); } active.Add(category); return(active.Contains(category)); }
public static void Test() { DoerAttrParser doerAttrParser = new DoerAttrParser(Client.instance.user); var result = ""; // result = doerAttrParser.ParseString("{#u.pos2}"); // result = doerAttrParser.Parse("{eval((5+4)*6)}");//eval() // result = doerAttrParser.Parse("{#cfgData.CfgItemData.1.icon_path}");// // result = doerAttrParser.Parse("{@hasSubString(abcdef,de)}");// // for (int i = 1; i < 100; i++) // { // result = doerAttrParser.Parse("{random(4,8)}"); //random() // LogCat.log(result); // } LogCat.log(result); }
public void RegisterListener(string type, Unit unit, object obj, string tag, MethodInvoker methodInvoker) { if (!this.listenerDict.ContainsKey(type)) { LogCat.error("Register Listener with undefine type()!", type); return; } var spellListenerInfo = new SpellListenerInfo(); spellListenerInfo.type = type; spellListenerInfo.unit = unit; spellListenerInfo.obj = obj; spellListenerInfo.tag = tag; spellListenerInfo.methodInvoker = methodInvoker; this.listenerDict[type].Add(spellListenerInfo); }
// Re-evaluate relative position of path void ReEvaluateRelativeTween() { GameObject tweenGO = GetTweenGO(); if (tweenGO == null) { LogCat.LogWarning(string.Format("{0} :: This DOTweenAnimation's target/GameObject is unset: the tween will not be created.", this.gameObject.name), this.gameObject); return; } if (animationType == DOTweenAnimationType.Move) { ((Tweener)tween).ChangeEndValue(tweenGO.transform.position + endValueV3, true); } else if (animationType == DOTweenAnimationType.LocalMove) { ((Tweener)tween).ChangeEndValue(tweenGO.transform.localPosition + endValueV3, true); } }
public void UnRegisterListener(string type, Unit unit, object obj, string tag) { if (!this.listenerDict.ContainsKey(type)) { LogCat.error("Unregister Listener with undefine type()!", type); return; } for (int i = this.listenerDict[type].Count - 1; i >= 0; i--) { var listenerInfo = this.listenerDict[type][i]; if (listenerInfo.unit == unit && listenerInfo.obj == obj && ObjectUtil.Equals(listenerInfo.tag, tag)) { this.listenerDict[type].RemoveAt(i); break; } } }
//卸下镶物 public bool EmbedOff(Item embed) { var list = this.oEmbeds.GetEmbeds_ToEdit(); if (!list.Contains(embed)) { LogCat.error(string.Format("{0} not contains embed:{1}", this, embed)); return(false); } if (!(this.OnEmbedOff(embed) && embed.OnEmbedOff(this))) { return(false); } list.Remove(embed); embed.SetEnv(null); return(true); }
public bool RemoveRole(Role role) { var list = this.oRoles.GetRoles_ToEdit(); if (!list.Contains(role)) { LogCat.error(string.Format("{0} not contains role:{1}", this, role)); return(false); } if (!(this.OnRemoveRole(role) && role.OnRemoveRole(this))) { return(false); } list.Remove(role); role.SetEnv(null); return(true); }
private static StringBuilder FormatMessage(LogCat cat, string message, Exception ex) { var builder = new StringBuilder(); builder.Append("####################日志开始####################\r\n"); builder.Append($"日志时间:{DateTime.Now: yyyy-MM-dd HH:mm:ss fff}。线程ID:{Thread.CurrentContext.ContextID}。\r\n"); builder.Append($"日志级别:{GetLogCat(cat)}。\r\n"); builder.Append($"日志消息:{message}\r\n"); if (ex != null) { builder.Append("----------异常信息----------\r\n"); builder.Append($"{ex.Message}\r\n"); builder.Append("----------调用堆栈----------\r\n"); builder.Append($"{ex.StackTrace}\r\n"); } builder.Append("####################日志结束####################\r\n"); return(builder); }