| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System;
- using System.Collections.Generic;
- using GFGGame.HotUpdate;
- using GFGGame.Launcher;
- using UnityEngine;
- namespace GFGGame
- {
- public class HotUpdateCodeLoaderHotUpdate : SingletonMonoBase<HotUpdateCodeLoaderHotUpdate>
- {
- public Type[] GetAllTypes()
- {
- var result = new List<Type>();
- foreach (string typeName in PreGeneratedTypes.AllTypeNames)
- {
- // 方法1:先尝试简单获取
- Type type = Type.GetType(typeName);
- // 方法2:如果失败,尝试从所有已加载程序集查找
- if (type == null)
- {
- foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
- {
- type = assembly.GetType(typeName);
- if (type != null) break;
- }
- }
- // 方法3:处理泛型类型(如`Namespace.Type`1, Assembly)
- if (type == null && typeName.Contains("`"))
- {
- try
- {
- int index = typeName.IndexOf(',');
- string shortName = index > 0 ? typeName.Substring(0, index) : typeName;
- type = Type.GetType(shortName);
- }
- catch
- {
- }
- }
- if (type != null)
- {
- result.Add(type);
- }
- else
- {
- Debug.LogWarning($"Type not found: {typeName}");
- }
- }
- return result.ToArray();
- }
- }
- }
|