static DebugLogConsole() { #if UNITY_EDITOR || !NETFX_CORE // Load commands in most common Unity assemblies HashSet <Assembly> assemblies = new HashSet <Assembly> { Assembly.GetAssembly(typeof(DebugLogConsole)) }; try { assemblies.Add(Assembly.Load("Assembly-CSharp")); } catch { } foreach (var assembly in assemblies) { foreach (var type in assembly.GetExportedTypes()) { foreach (var method in type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly)) { foreach (var attribute in method.GetCustomAttributes(typeof(ConsoleMethodAttribute), false)) { ConsoleMethodAttribute consoleMethod = attribute as ConsoleMethodAttribute; if (consoleMethod != null) { AddCommand(consoleMethod.Command, consoleMethod.Description, method); } } } } } #endif AddCommand("help", "Prints all commands", LogAllCommands); AddCommand("sysinfo", "Prints system information", LogSystemInfo); }
static DebugLogConsole() { parseFunctions = new Dictionary <Type, ParseFunction>() { { typeof(string), ParseString }, { typeof(bool), ParseBool }, { typeof(int), ParseInt }, { typeof(uint), ParseUInt }, { typeof(long), ParseLong }, { typeof(ulong), ParseULong }, { typeof(byte), ParseByte }, { typeof(sbyte), ParseSByte }, { typeof(short), ParseShort }, { typeof(ushort), ParseUShort }, { typeof(char), ParseChar }, { typeof(float), ParseFloat }, { typeof(double), ParseDouble }, { typeof(decimal), ParseDecimal }, { typeof(Vector2), ParseVector2 }, { typeof(Vector3), ParseVector3 }, { typeof(Vector4), ParseVector4 }, { typeof(GameObject), ParseGameObject } }; typeReadableNames = new Dictionary <Type, string>() { { typeof(string), "String" }, { typeof(bool), "Boolean" }, { typeof(int), "Integer" }, { typeof(uint), "Unsigned Integer" }, { typeof(long), "Long" }, { typeof(ulong), "Unsigned Long" }, { typeof(byte), "Byte" }, { typeof(sbyte), "Short Byte" }, { typeof(short), "Short" }, { typeof(ushort), "Unsigned Short" }, { typeof(char), "Char" }, { typeof(float), "Float" }, { typeof(double), "Double" }, { typeof(decimal), "Decimal" }, { typeof(Vector2), "Vector2" }, { typeof(Vector3), "Vector3" }, { typeof(Vector4), "Vector4" }, { typeof(GameObject), "GameObject" } }; #if UNITY_EDITOR || !NETFX_CORE // Load commands in most common Unity assemblies HashSet <Assembly> assemblies = new HashSet <Assembly> { Assembly.GetAssembly(typeof(DebugLogConsole)) }; try { assemblies.Add(Assembly.Load("Assembly-CSharp")); } catch { } foreach (var assembly in assemblies) { foreach (var type in assembly.GetExportedTypes()) { foreach (var method in type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly)) { foreach (var attribute in method.GetCustomAttributes(typeof(ConsoleMethodAttribute), false)) { ConsoleMethodAttribute consoleMethod = attribute as ConsoleMethodAttribute; if (consoleMethod != null) { AddCommand(consoleMethod.Command, consoleMethod.Description, method); } } } } } #else AddCommandStatic("help", "Prints all commands", "LogAllCommands", typeof(DebugLogConsole)); AddCommandStatic("sysinfo", "Prints system information", "LogSystemInfo", typeof(DebugLogConsole)); #endif }