/// <summary> /// /// </summary> /// <param name="monos"></param> private void OnLoadMonoScript(params MonoScript[] monos) { foreach (var item in monos) { if (item == null || item.GetClass() == null) { continue; } var old = refineObj.refineList.Find(x => x.type == item.GetClass().ToString()); if (old == null) { var refineItem = new RefineItem(item); refineObj.refineList.Add(refineItem); LoopInsertItem(refineItem, refineObj.refineList); } else { old.Update(item); } } }
private void LoopInsertItem(RefineItem item, List <RefineItem> refineList) { //遍历参数 foreach (var arg in item.arguments) { if (!string.IsNullOrEmpty(arg.subType)) { var type = Assembly.Load(arg.subAssemble).GetType(arg.subType); if (type == null) { continue; } if (type.IsGenericType) { type = type.GetGenericArguments()[0]; } else if (type.IsArray) { type = type.GetElementType(); } if (RefineUtility.IsInternalScript(type)) { continue; } if (IsIgnored(type)) { continue; } var old = refineObj.refineList.Find(x => x.type == type.ToString()); if (old == null) { var refineItem = new RefineItem(type); refineObj.refineList.Add(refineItem); LoopInsertItem(refineItem, refineList); } else { old.Update(type); } } } var currentType = Assembly.Load(item.assemble).GetType(item.type); if (currentType == null) { currentType = Type.GetType(item.type); } if (currentType == null) { Debug.Log(item.type + ": load empty"); return; } //遍历泛型类 if (currentType.IsGenericType) { var gtypes = currentType.GetGenericArguments(); foreach (var gtype in gtypes) { if (RefineUtility.IsInternalScript(gtype)) { continue; } if (IsIgnored(gtype)) { continue; } var old = refineObj.refineList.Find(x => x.type == gtype.ToString()); if (old == null) { var refineItem = new RefineItem(gtype); refineObj.refineList.Add(refineItem); LoopInsertItem(refineItem, refineObj.refineList); } else { old.Update(gtype); } } } //遍历类父级 while (currentType != null && currentType.BaseType != null) { currentType = currentType.BaseType; if (RefineUtility.IsInternalScript(currentType)) { continue; } if (IsIgnored(currentType)) { continue; } var old = refineObj.refineList.Find(x => x.type == currentType.ToString()); if (old == null) { var refineItem = new RefineItem(currentType); refineObj.refineList.Add(refineItem); LoopInsertItem(refineItem, refineObj.refineList); } else { old.Update(currentType); } } }