public static void LogObj <T>(T obj, string tag = "", bool timePrefix = false) { if (EnableLog) { var log = timePrefix ? $"[{BuildTimeStamp()}]" + tag : tag; VeeUtils.LogObj(obj, log); } }
/// <summary> /// 程序应该确保condition为true,否则触发Assert,并显示msg /// </summary> /// <param name="condition"></param> /// <param name="msg"></param> /// <param name="timePrefix"></param> public static void Assert(bool condition, string msg = "") { //#if UNITY_EDITOR if (EnableAssert) { msg = VeeUtils.CheckStringValid(msg) ? msg : "Assert Failed"; msg = $"[{BuildTimeStamp()}]" + msg; UnityEngine.Debug.Assert(condition, msg); } //#endif }
public static List <string> FindCodeFiles(string fileNameWithoutExt, List <string> folders = null) { if (folders == null || folders.Count <= 0) { folders = new List <string>() { "Assets/Game/Scripts" } } ; var guids = FindAssetsExactly(fileNameWithoutExt, "t:Object", folders.ToArray()); var ret = guids.Select(g => AssetDatabase.GUIDToAssetPath(g)).ToList(); VeeUtils.LogObj(ret); return(ret); }
private void DrawFps() { if (mLastFps > 50) { GUI.color = new Color(0, 1, 0); } else if (mLastFps > 40) { GUI.color = new Color(1, 1, 0); } else { GUI.color = new Color(1.0f, 0, 0); } VeeUtils.GUIText(new Vector2(10, 40), "fps: " + mLastFps, 30); }
public static void Check(BindRoot bindRoot) { var root = bindRoot.gameObject; var scriptName = bindRoot.ScriptName; if (!VeeUtils.CheckStringValid(scriptName)) { Debug.LogWarning("Bind Root Name is NOT valid on gameobject " + root.name); return; } var fullClassName = scriptName; if (VeeUtils.CheckStringValid(bindRoot.NameSpace)) { fullClassName = bindRoot.NameSpace + "." + scriptName; } var types = ReflectionHelper.GetTypesInAllLoadedAssemblies(t => t.FullName == fullClassName).ToList(); if (types.Count <= 0) { Debug.LogWarning($"Not Found class [{fullClassName}] in Assemblies"); return; } if (types.Count > 1) { Debug.LogWarning($"Multy Type found for class [{scriptName}], please fill nameSpace "); return; } var comType = types[0]; var com = bindRoot.gameObject.GetComponent(comType); if (com == null) { Debug.LogWarning($"Not Found {fullClassName} Component on {root.name}"); return; } var eles = root.GetComponentsInChildren <BindElement>(true); var oldNames = new List <string>(); foreach (var ele in eles) { if (ele.RootName != scriptName) { continue; } var eleBindName = ele.BindName; if (oldNames.Contains(eleBindName)) { Debug.LogWarning($"Checking bindname [{eleBindName}] on [{ele.gameObject.name}], name Repeated !!!"); } else { oldNames.Add(eleBindName); Debug.Log($"Checking bindname [{eleBindName}] on [{ele.gameObject.name}]"); } var bindField = comType.GetField(eleBindName); if (bindField == null) { Debug.LogWarning($"BindElement [{eleBindName}] is not a field of {scriptName}"); continue; } var fieldType = bindField.FieldType; var eleType = ele.EleType; if (fieldType != eleType) { Debug.LogWarning($"BindElement [{eleBindName}] Type [{ele.Type}] not matching field type [{bindField.FieldType}] in {scriptName}"); continue; } UnityEngine.Object eleClass = null; if (fieldType.FullName == "UnityEngine.GameObject") { eleClass = ele.gameObject; } else { eleClass = ele.gameObject.GetComponent(fieldType); } if (eleClass == null) { Debug.LogWarning($"Not Found [{fieldType}] Class on [{ele.gameObject}], bind name [{eleBindName}]"); continue; } if (bindField.GetValue(com) != (object)eleClass) { Debug.Log($"[{eleBindName}] is filled"); bindField.SetValue(com, eleClass); } } Debug.Log($"Check finished on [{bindRoot.ScriptName}]"); }