/// <summary> /// 初始化控制台 /// </summary> /// <param name="assemblyName">扩展的控制台窗口所在的程序集</param> public static void Initialize(bool showFPS = true, string assemblyName = AssemblyUtility.UnityDefaultAssemblyName) { if (showFPS) { _fpsCounter = new FPSCounter(); } // 加载背景纹理 string textureName = "console_background"; _bgTexture = Resources.Load <Texture>(textureName); if (_bgTexture == null) { UnityEngine.Debug.LogWarning($"Not found {textureName} texture in Resources folder."); } // 获取所有控制台窗口类 List <Type> types = AssemblyUtility.GetAssignableAttributeTypes(AssemblyUtility.MotionFrameworkAssemblyName, typeof(IConsoleWindow), typeof(ConsoleAttribute)); List <Type> temps = AssemblyUtility.GetAssignableAttributeTypes(assemblyName, typeof(IConsoleWindow), typeof(ConsoleAttribute)); types.AddRange(temps); for (int i = 0; i < types.Count; i++) { ConsoleAttribute attribute = (ConsoleAttribute)Attribute.GetCustomAttribute(types[i], typeof(ConsoleAttribute)); WindowWrapper wrapper = new WindowWrapper() { ClassType = types[i], Title = attribute.Title, Priority = attribute.Order, }; _wrappers.Add(wrapper); } // 根据优先级排序 _wrappers.Sort(); // 创建实例类 for (int i = 0; i < _wrappers.Count; i++) { WindowWrapper wrapper = _wrappers[i]; wrapper.Instance = (IConsoleWindow)Activator.CreateInstance(wrapper.ClassType); } // 标题列表 List <string> titles = new List <string>(); for (int i = 0; i < _wrappers.Count; i++) { titles.Add(_wrappers[i].Title); } _toolbarTitles = titles.ToArray(); }
/// <summary> /// 初始化控制台 /// </summary> public static void Initialize() { // 加载背景纹理 string textureName = "console_background"; _bgTexture = Resources.Load <Texture>(textureName); if (_bgTexture == null) { UnityEngine.Debug.LogWarning($"Not found {textureName} texture in Resources folder."); } // 获取所有调试类 List <Type> allTypes = AssemblyUtility.GetAssignableAttributeTypes(typeof(IConsoleWindow), typeof(ConsoleAttribute)); for (int i = 0; i < allTypes.Count; i++) { ConsoleAttribute attribute = (ConsoleAttribute)Attribute.GetCustomAttribute(allTypes[i], typeof(ConsoleAttribute)); WindowWrapper wrapper = new WindowWrapper() { ClassType = allTypes[i], Title = attribute.Title, Priority = attribute.Order, }; _wrappers.Add(wrapper); } // 根据优先级排序 _wrappers.Sort(); // 创建实例类 for (int i = 0; i < _wrappers.Count; i++) { WindowWrapper wrapper = _wrappers[i]; wrapper.Instance = (IConsoleWindow)Activator.CreateInstance(wrapper.ClassType); } // 标题列表 List <string> titles = new List <string>(); for (int i = 0; i < _wrappers.Count; i++) { titles.Add(_wrappers[i].Title); } _toolbarTitles = titles.ToArray(); }