/// <summary> /// 加载当前模块重要的元件 /// </summary> private void LoadImportentWidgetsAndAddLocalization() { //判断脚本添加的元件组件是否符合规范 if (!ReflectionManager.GetInstance().TypeIsExtentOrEquel( currentModuleWidgetScript, "UIWidgetBase")) { //命名不规范,依旧使用基类组件 currentModuleWidgetScript = "UIFrame.UIWidgetBase"; } //遍历当前对象的所有子对象 Transform[] allChild = transform.GetComponentsInChildren <Transform>(); //遍历所有的子对象 for (int i = 0; i < allChild.Length; i++) { //遍历所有的元件尾部标记符号 for (int j = 0; j < SystemDefine.IMPORTENT_WIDGET_TOKEN.Length; j++) { //判断当前子对象的名字是否以该符号结尾 if (allChild[i].name.EndsWith(SystemDefine.IMPORTENT_WIDGET_TOKEN[j])) { //添加该脚本组件 UIWidgetBase uiWidget = allChild[i].gameObject.AddComponent( Type.GetType(currentModuleWidgetScript)) as UIWidgetBase; //赋值给脚本所在的模块 uiWidget._currentModule = this; //添加到字典 _uiWidgets.Add(allChild[i].name, uiWidget); break; } } //添加本地化组件 AddLocalizationTextComponent(allChild[i]); } }