From 611f1ffab97c57f655d507f7833f059a7fa6f0ee Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Wed, 19 Apr 2023 14:20:05 +0800 Subject: [PATCH] Update GameFrameworkEntry.cs --- .../Runtime/GameFramework/GameFrameworkEntry.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Assets/TEngine/Runtime/GameFramework/GameFrameworkEntry.cs b/Assets/TEngine/Runtime/GameFramework/GameFrameworkEntry.cs index 7833c06a..ddad7a37 100644 --- a/Assets/TEngine/Runtime/GameFramework/GameFrameworkEntry.cs +++ b/Assets/TEngine/Runtime/GameFramework/GameFrameworkEntry.cs @@ -47,22 +47,18 @@ namespace TEngine /// 如果要获取的游戏框架模块不存在,则自动创建该游戏框架模块。 public static T GetModule() where T : class { - Type interfaceType = typeof(T); - if (!interfaceType.IsInterface) + Type module = typeof(T); + + if (module.FullName != null && !module.FullName.StartsWith("TEngine.", StringComparison.Ordinal)) { - throw new GameFrameworkException(Utility.Text.Format("You must get module by interface, but '{0}' is not.", interfaceType.FullName)); + throw new GameFrameworkException(Utility.Text.Format("You must get a Game Framework module, but '{0}' is not.", module.FullName)); } - if (!interfaceType.FullName.StartsWith("TEngine.", StringComparison.Ordinal)) - { - throw new GameFrameworkException(Utility.Text.Format("You must get a Game Framework module, but '{0}' is not.", interfaceType.FullName)); - } - - string moduleName = Utility.Text.Format("{0}.{1}", interfaceType.Namespace, interfaceType.Name.Substring(1)); + string moduleName = Utility.Text.Format("{0}.{1}", module.Namespace, module.Name.Substring(1)); Type moduleType = Type.GetType(moduleName); if (moduleType == null) { - moduleName = Utility.Text.Format("{0}.{1}", interfaceType.Namespace, interfaceType.Name); + moduleName = Utility.Text.Format("{0}.{1}", module.Namespace, module.Name); moduleType = Type.GetType(moduleName); if (moduleType == null) {