[remove] 移除HybridCLRSettings的collectAssetReferenceTypes选项
parent
b5a7899657
commit
275a3bd01a
|
@ -26,7 +26,7 @@ namespace HybridCLR.Editor.Commands
|
|||
|
||||
List<string> hotfixAssemblies = SettingsUtil.HotUpdateAssemblyNamesExcludePreserved;
|
||||
|
||||
var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies), HybridCLRSettings.Instance.collectAssetReferenceTypes);
|
||||
var analyzer = new Analyzer(MetaUtil.CreateHotUpdateAndAOTAssemblyResolver(target, hotfixAssemblies));
|
||||
var refTypes = analyzer.CollectRefs(hotfixAssemblies);
|
||||
|
||||
Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssemblies.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}");
|
||||
|
|
|
@ -14,12 +14,10 @@ namespace HybridCLR.Editor.Link
|
|||
public class Analyzer
|
||||
{
|
||||
private readonly IAssemblyResolver _resolver;
|
||||
private readonly bool _analyzeAssetType;
|
||||
|
||||
public Analyzer(IAssemblyResolver resolver, bool analyzeAssetType)
|
||||
public Analyzer(IAssemblyResolver resolver)
|
||||
{
|
||||
_resolver = resolver;
|
||||
_analyzeAssetType = analyzeAssetType;
|
||||
}
|
||||
|
||||
public HashSet<TypeRef> CollectRefs(List<string> rootAssemblies)
|
||||
|
@ -31,7 +29,7 @@ namespace HybridCLR.Editor.Link
|
|||
var typeRefs = new HashSet<TypeRef>(TypeEqualityComparer.Instance);
|
||||
foreach (var rootAss in rootAssemblies)
|
||||
{
|
||||
var dnAss = assCollector.LoadModule(rootAss, _analyzeAssetType);
|
||||
var dnAss = assCollector.LoadModule(rootAss, false);
|
||||
foreach (var type in dnAss.GetTypeRefs())
|
||||
{
|
||||
if (!rootAssemblyNames.Contains(type.DefinitionAssembly.Name.ToString()))
|
||||
|
@ -41,58 +39,9 @@ namespace HybridCLR.Editor.Link
|
|||
}
|
||||
}
|
||||
|
||||
if (_analyzeAssetType)
|
||||
{
|
||||
var modsExludeRoots = assCollector.LoadedModules
|
||||
.Where(e => !rootAssemblyNames.Contains(e.Key))
|
||||
.ToDictionary(e => e.Key, e => e.Value);
|
||||
CollectObjectTypeInAssets(modsExludeRoots, typeRefs);
|
||||
}
|
||||
|
||||
assCollector.Dispose();
|
||||
return typeRefs;
|
||||
}
|
||||
}
|
||||
|
||||
public void CollectObjectTypeInAssets(Dictionary<string, ModuleDefMD> mods, HashSet<TypeRef> typeRefs)
|
||||
{
|
||||
var objTypes = new HashSet<Type>();
|
||||
string[] guids = AssetDatabase.FindAssets("t:Object", new[] { "Assets" });
|
||||
foreach (string guid in guids)
|
||||
{
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
Type mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
||||
if (mainAssetType == typeof(SceneAsset))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityEngine.Object[] objs = AssetDatabase.LoadAllAssetsAtPath(assetPath);
|
||||
foreach (UnityEngine.Object obj in objs)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
objTypes.Add(obj.GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var importers = mods.ToDictionary(e => e.Key, e => new Importer(e.Value));
|
||||
//Debug.Log($"importers count:{importers.Count} importers:{string.Join(",", importers.Keys)}");
|
||||
foreach (var type in objTypes)
|
||||
{
|
||||
if (importers.TryGetValue(type.Assembly.GetName().Name, out var im))
|
||||
{
|
||||
typeRefs.Add((TypeRef)im.Import(type));
|
||||
//Debug.Log($"== add asset type:{type}");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Debug.Log($"== ignore asset type:{type} {type.Assembly.GetName().Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ namespace HybridCLR.Editor
|
|||
private SerializedProperty _externalHotUpdateAssembliyDirs;
|
||||
private SerializedProperty _strippedAOTDllOutputRootDir;
|
||||
private SerializedProperty _patchAOTAssemblies;
|
||||
private SerializedProperty _collectAssetReferenceTypes;
|
||||
private SerializedProperty _outputLinkFile;
|
||||
private SerializedProperty _outputAOTGenericReferenceFile;
|
||||
private SerializedProperty _maxGenericReferenceIteration;
|
||||
|
@ -48,7 +47,6 @@ namespace HybridCLR.Editor
|
|||
_externalHotUpdateAssembliyDirs = _serializedObject.FindProperty("externalHotUpdateAssembliyDirs");
|
||||
_strippedAOTDllOutputRootDir = _serializedObject.FindProperty("strippedAOTDllOutputRootDir");
|
||||
_patchAOTAssemblies = _serializedObject.FindProperty("patchAOTAssemblies");
|
||||
_collectAssetReferenceTypes = _serializedObject.FindProperty("collectAssetReferenceTypes");
|
||||
_outputLinkFile = _serializedObject.FindProperty("outputLinkFile");
|
||||
_outputAOTGenericReferenceFile = _serializedObject.FindProperty("outputAOTGenericReferenceFile");
|
||||
_maxGenericReferenceIteration = _serializedObject.FindProperty("maxGenericReferenceIteration");
|
||||
|
@ -137,7 +135,6 @@ namespace HybridCLR.Editor
|
|||
EditorGUILayout.PropertyField(_externalHotUpdateAssembliyDirs);
|
||||
EditorGUILayout.PropertyField(_strippedAOTDllOutputRootDir);
|
||||
EditorGUILayout.PropertyField(_patchAOTAssemblies);
|
||||
EditorGUILayout.PropertyField(_collectAssetReferenceTypes);
|
||||
EditorGUILayout.PropertyField(_outputLinkFile);
|
||||
EditorGUILayout.PropertyField(_outputAOTGenericReferenceFile);
|
||||
EditorGUILayout.PropertyField(_maxGenericReferenceIteration);
|
||||
|
|
|
@ -38,9 +38,6 @@ namespace HybridCLR.Editor
|
|||
[Header("补充元数据AOT dlls")]
|
||||
public string[] patchAOTAssemblies;
|
||||
|
||||
[Header("生成link.xml时扫描asset中引用的类型")]
|
||||
public bool collectAssetReferenceTypes;
|
||||
|
||||
[Header("生成的link.xml路径")]
|
||||
public string outputLinkFile = "HybridCLRData/Generated/link.xml";
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.focus-creative-games.hybridclr_unity",
|
||||
"version": "2.0.1",
|
||||
"version": "2.0.2",
|
||||
"displayName": "HybridCLR",
|
||||
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
|
||||
"category": "Runtime",
|
||||
|
|
Loading…
Reference in New Issue