void Init() { if (!runtimeInspector) { runtimeInspector = GetComponentInChildren <RuntimeInspector>(true); } if (!runtimeConsole) { runtimeConsole = GetComponentInChildren <RuntimeConsole>(true); } RuntimeConsole.instance = runtimeConsole; if (runtimeInspector && !runtimeInspector.gameObject.activeInHierarchy) { SetActiveDeactive(runtimeInspector.gameObject); } if (runtimeConsole && !runtimeConsole.gameObject.activeInHierarchy) { SetActiveDeactive(runtimeConsole.gameObject); } if (!runtimeConsole && runtimeInspector) { RuntimeConsole.accessLevel = AccessLevel.Admin; } if (runtimeInspector || runtimeConsole) { RuntimeInspector.InitAssemblies(); } }
void Awake() { instance = this; selectionIndicatorGO = transform.GetChild(0).gameObject; SetSelectionSphereRadius(); skin = windowData.skin; texArrowFolded = windowData.texArrowFolded; texArrowUnfolded = windowData.texArrowUnfolded; inspectorWindow = windowData.inspectorWindow; hierarchyWindow = windowData.hierarchyWindow; SetActive(showOnStart); // DontDestroyOnLoad(gameObject); if (enableCameraOnStart) { useNavigationCamera.Value = true; EnableCamControl(); } wrapButton = new GUIStyle(skin.button); wrapButton.wordWrap = true; wrapTextField = new GUIStyle(skin.textField); wrapTextField.wordWrap = true; drawEnum = new DrawEnum(skin); RuntimeConsole.Register(this); refreshHierarchySearch = 1; refreshInspectorSearch = 1; }
int PrintNumbers(int count) { for (int i = 0; i < count; i++) { RuntimeConsole.Log("number " + i, new Color((i / 255.0f) % 1, 1, 0), true); } return(count); }
void OnDestroy() { if (instance == this) { instance = null; } Unregister(this); }
void OnDestroy() { RuntimeConsole.Unregister(this); if (instance == this) { instance = null; } }
static bool ChangeType(Type t, FastQueue <string> paramQueue, out object result) { if (paramQueue.Count == 0) { RuntimeConsole.LogResultError("Not enough parameters"); result = null; return(false); } string value = paramQueue.Dequeue(); return(ChangeType(t, value, out result)); }
public static bool ChangeType(Type t, string value, out object result, bool logError = true) { value = value.Trim(); // Debug.Log("TryParse: " + value); if (t == typeof(string)) { result = value; return(true); } else if (t.IsEnum) { try { result = Enum.Parse(t, value, true); return(true); } catch (Exception) { if (logError) { RuntimeConsole.LogResultError("Cannot find '" + value + "'"); } } } else { try { result = Convert.ChangeType(value, t); return(true); } catch (Exception) { if (logError) { RuntimeConsole.LogResultError("Cannot parse " + value); } } } result = null; return(false); }
static public void InitAssemblies(ref bool hasInitAssemblies, FastList <CustomAssembly> customAssemblies, Dictionary <NamespaceTypes, RuntimeInspector.DrawInfo> namespaceTypesLookup, Dictionary <string, FastList <Type> > typeNameLookup) { hasInitAssemblies = true; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { CustomAssembly customAssembly = new CustomAssembly(); Assembly assembly = customAssembly.assembly = assemblies[i]; customAssemblies.Add(customAssembly); string name = assembly.GetName().Name; customAssembly.name = name; bool isCSharpAssembly = false; if (name.IndexOf("unity", StringComparison.OrdinalIgnoreCase) != -1) { customAssembly.type = AssemblyType.Unity; } else if (name.IndexOf("system", StringComparison.OrdinalIgnoreCase) != -1 || name == "mscorlib") { customAssembly.type = AssemblyType.System; } else if (name.IndexOf("mono", StringComparison.OrdinalIgnoreCase) != -1) { customAssembly.type = AssemblyType.Mono; } else { if (name.Contains("Assembly-CSharp")) { isCSharpAssembly = true; } customAssembly.type = AssemblyType.Other; } Type[] types = assembly.GetTypes(); for (int j = 0; j < types.Length; j++) { Type type = types[j]; if (isCSharpAssembly) { RuntimeConsole.RegisterStaticType(type); } CustomType customType = new CustomType(customAssembly, type); customAssembly.allTypes.Add(customType); string namespaceString = type.Namespace; if (namespaceString == null) { customAssembly.types.Add(customType); } else { NamespaceTypes namespaceTypes; if (!customAssembly.namespaceLookup.lookup.TryGetValue(namespaceString, out namespaceTypes)) { namespaceTypes = new NamespaceTypes(customAssembly, namespaceString); customAssembly.namespaceLookup.Add(namespaceString, namespaceTypes); } namespaceTypes.types.Add(new CustomType(namespaceTypes, type)); } string typeName = type.Name; FastList <Type> typeList; if (!typeNameLookup.TryGetValue(typeName, out typeList)) { if (typeList == null) { typeList = new FastList <Type>(); } typeNameLookup[typeName] = typeList; } typeList.Add(type); } } Array.Sort(customAssemblies.items, 0, customAssemblies.Count); for (int i = 0; i < customAssemblies.Count; i++) { customAssemblies.items[i].Sort(); } RuntimeConsole.SortCommandsTable(); }
public void UnityDebugLog(string logString, string stackTraceString, LogType logType, bool isMainThread, int threadId = -1, System.Diagnostics.StackTrace stackTrace = null, EntryType2 entryType = EntryType2.Unity, bool closeLi = true) { if (!isLogEnabled || sw == null) { return; } // float realTime = timeSinceStartup.ElapsedMilliseconds / 1000f; if (currentFrame != lastFrame) { lastFrame = currentFrame; sw.Write("</ul><br><strong><span style=\"color:#508EA1;"); sw.Write(frameFontSizeString); sw.Write("[Frame "); sw.Write(currentFrame.ToString("D6")); sw.Write("][Time "); sw.Write(Helper.ToTimeFormat(frameTime)); // sw.Write("] ***********************************************************************************************"); sw.Write("] -----------------------------------------------------------------------------------------------"); sw.Write("</span></strong><ul>"); } if (logType == LogType.Error) { sw.Write("<li style =\"color:#FF0000;"); } else if (logType == LogType.Exception) { sw.Write("<li style =\"color:#9D00FF;"); } else if (logType == LogType.Warning) { sw.Write("<li style =\"color:#FFFF00;"); } else if (entryType == EntryType2.Unity) { sw.Write("<li style =\"color:#F0F0F0;"); } else { if (!closeLi) { sw.Write("<li style =\"color:#"); } else { sw.Write("<span style =\"color:#"); } if (entryType == EntryType2.Command) { sw.Write(ColorUtility.ToHtmlStringRGB(Color.green) + ";"); } else if (entryType == EntryType2.CommandResult) { sw.Write(ColorUtility.ToHtmlStringRGB(Helper.colCommandResult) + ";"); } else if (entryType == EntryType2.CommandFault) { sw.Write(ColorUtility.ToHtmlStringRGB(Helper.colCommandResultFailed) + ";"); } } sw.Write(logFontSizeString); if (entryType != EntryType2.Unity) { sw.Write("<strong>"); } // sw.Write(logString.Replace("\n", "<br>")); sw.Write(logString); if (entryType != EntryType2.Unity) { sw.Write("</strong>"); } if (!isMainThread) { sw.Write(" <i>[Thread "); sw.Write(threadId); sw.Write("]</i>"); } sw.Write("</br>"); string[] lines = null; if (logType == LogType.Exception) { sw.Write("<span style=\"color:#7D00DF;"); sw.Write(stackFontSizeString); lines = stackTraceString.Split('\n'); for (int i = 0; i < lines.Length; i++) { sw.Write(lines[i]); if (i < lines.Length - 1) { sw.Write("<br>"); } } sw.Write("</span>"); } else { bool useStackTrace = (entryType == EntryType2.Unity && UseStackTrace(logType)); if (useStackTrace) { if (logType == LogType.Error) { sw.Write("<span style=\"color:#A00000;"); } else if (logType == LogType.Warning) { sw.Write("<span style=\"color:#A0A000;"); } else { sw.Write("<span style=\"color:#909090;"); } sw.Write(stackFontSizeString); int count; if (logType == LogType.Log && normalLogOnlyFirstLineStackTrace) { count = 1; } else { count = stackTrace.FrameCount; } if (RuntimeConsole.instance) { lines = new string[count]; } for (int i = 0; i < count; i++) { var frame = stackTrace.GetFrame(i); if (frame != null) { var method = frame.GetMethod(); string name = method.DeclaringType.Name; sw.Write(name); sw.Write("."); sw.Write(method); if (isEditor || isDebugBuild) { sw.Write(":"); int lineNumber = frame.GetFileLineNumber(); sw.Write(lineNumber); if (RuntimeConsole.instance) { lines[i] = name + "." + method + ":" + lineNumber; } } else if (RuntimeConsole.instance) { lines[i] = name + "." + method; } sw.Write("<br>"); } } sw.Write("</style></span>"); } } if (entryType == EntryType2.Unity) { if (RuntimeConsole.instance) { RuntimeConsole.Log(logString, lines, logType, Color.white, threadId); } } if (closeLi) { sw.Write("</li>"); sw.Write("<span style=\"font-size:9px;\"><br></span>"); } else { sw.Write("</span>"); } sw.Flush(); }
void OnDestroy() { RuntimeConsole.Unregister(this); }
void Awake() { RuntimeConsole.Register(this); doMath = Multiply; }
public MemberData(Type objType, MemberInfo member, MemberType memberType, Color colorPublic, Color colorProtected, Color colorPrivate) { this.member = member; this.memberType = memberType; if (memberType == MemberType.Field) { field = (FieldInfo)member; name = field.Name; type = field.FieldType; isStatic = field.IsStatic; isConstant = field.IsLiteral; if (field.IsPublic) { scope = Scope.Public; } else if (field.IsFamily) { scope = Scope.Protected; } else if (field.IsPrivate) { scope = Scope.Private; } } else if (memberType == MemberType.Property) { prop = (PropertyInfo)member; name = prop.Name; type = prop.PropertyType; method = prop.GetGetMethod(true); if (method == null) { method = prop.GetSetMethod(true); } if (method != null) { isStatic = method.IsStatic; if (method.IsPublic) { scope = Scope.Public; } else if (method.IsPrivate) { scope = Scope.Private; } else if (method.IsFamily) { scope = Scope.Protected; } } } else { method = (MethodInfo)member; parameters = method.GetParameters(); validInvokeParameters = RuntimeConsole.ValidParams(type, method, parameters, false); name = method.ToString(); type = method.DeclaringType; isStatic = method.IsStatic; if (method.IsPublic) { scope = Scope.Public; } else if (method.IsPrivate) { scope = Scope.Private; } else if (method.IsFamily) { scope = Scope.Protected; } } isString = (type == typeof(string)); isClass = type.IsClass; isStruct = type.IsValueType && !type.IsPrimitive && !type.IsEnum; isArray = type.IsArray; isInterface = type.IsInterface; typeName = "(" + type.Name + ")"; if (scope == Scope.Public) { scopeColor = colorPublic; scopeToolTip = "Is Public"; } else if (scope == Scope.Protected) { scopeColor = colorProtected; scopeToolTip = "Is Protected"; } else { scopeColor = colorPrivate; scopeToolTip = "Is Private"; } }