[new] HybridCLRSettings新增collectAssetReferenceTypes字段指示生成link.xml是否扫描资源中引用的类型
parent
a74130618e
commit
d7a1765146
|
@ -45,7 +45,7 @@ namespace HybridCLR.Editor.Commands
|
|||
}
|
||||
}
|
||||
|
||||
var analyzer = new Analyzer(MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget));
|
||||
var analyzer = new Analyzer(MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget), HybridCLRSettings.Instance.collectAssetReferenceTypes);
|
||||
var refTypes = analyzer.CollectRefs(hotfixAssembles);
|
||||
|
||||
Debug.Log($"[LinkGeneratorCommand] hotfix assembly count:{hotfixAssembles.Count}, ref type count:{refTypes.Count} output:{Application.dataPath}/{ls.outputLinkFile}");
|
||||
|
|
|
@ -14,10 +14,12 @@ namespace HybridCLR.Editor.Link
|
|||
public class Analyzer
|
||||
{
|
||||
private readonly IAssemblyResolver _resolver;
|
||||
private readonly bool _analyzeAssetType;
|
||||
|
||||
public Analyzer(IAssemblyResolver resolver)
|
||||
public Analyzer(IAssemblyResolver resolver, bool analyzeAssetType)
|
||||
{
|
||||
_resolver = resolver;
|
||||
_analyzeAssetType = analyzeAssetType;
|
||||
}
|
||||
|
||||
public HashSet<TypeRef> CollectRefs(List<Assembly> rootAssemblies)
|
||||
|
@ -46,11 +48,13 @@ namespace HybridCLR.Editor.Link
|
|||
}
|
||||
}
|
||||
|
||||
var modsExludeRoots = assCollector.LoadedModules
|
||||
.Where(e => !rootAssemblyName.Contains(e.Key))
|
||||
.ToDictionary(e => e.Key, e => e.Value);
|
||||
CollectObjectTypeInAssets(modsExludeRoots, typeRefs);
|
||||
|
||||
if (_analyzeAssetType)
|
||||
{
|
||||
var modsExludeRoots = assCollector.LoadedModules
|
||||
.Where(e => !rootAssemblyName.Contains(e.Key))
|
||||
.ToDictionary(e => e.Key, e => e.Value);
|
||||
CollectObjectTypeInAssets(modsExludeRoots, typeRefs);
|
||||
}
|
||||
|
||||
assCollector.Dispose();
|
||||
return typeRefs;
|
||||
|
@ -74,7 +78,10 @@ namespace HybridCLR.Editor.Link
|
|||
UnityEngine.Object[] objs = AssetDatabase.LoadAllAssetsAtPath(assetPath);
|
||||
foreach (UnityEngine.Object obj in objs)
|
||||
{
|
||||
objTypes.Add(obj.GetType());
|
||||
if (obj != null)
|
||||
{
|
||||
objTypes.Add(obj.GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace HybridCLR.Editor
|
|||
private SerializedProperty m_CloneFromGitee;
|
||||
private SerializedProperty m_HotUpdateAssemblyDefinitions;
|
||||
private SerializedProperty m_HotUpdateAssemblies;
|
||||
private SerializedProperty m_collectAssetReferenceTypes;
|
||||
private SerializedProperty m_OutputLinkFile;
|
||||
private SerializedProperty m_OutputAOTGenericReferenceFile;
|
||||
private SerializedProperty m_MaxGenericReferenceIteration;
|
||||
|
@ -32,6 +33,7 @@ namespace HybridCLR.Editor
|
|||
m_CloneFromGitee = m_SerializedObject.FindProperty("cloneFromGitee");
|
||||
m_HotUpdateAssemblyDefinitions = m_SerializedObject.FindProperty("hotUpdateAssemblyDefinitions");
|
||||
m_HotUpdateAssemblies = m_SerializedObject.FindProperty("hotUpdateAssemblies");
|
||||
m_collectAssetReferenceTypes = m_SerializedObject.FindProperty("collectAssetReferenceTypes");
|
||||
m_OutputLinkFile = m_SerializedObject.FindProperty("outputLinkFile");
|
||||
m_OutputAOTGenericReferenceFile = m_SerializedObject.FindProperty("outputAOTGenericReferenceFile");
|
||||
m_MaxGenericReferenceIteration = m_SerializedObject.FindProperty("maxGenericReferenceIteration");
|
||||
|
@ -104,6 +106,7 @@ namespace HybridCLR.Editor
|
|||
EditorGUILayout.PropertyField(m_UseGlobalIl2cpp);
|
||||
EditorGUILayout.PropertyField(m_HotUpdateAssemblyDefinitions);
|
||||
EditorGUILayout.PropertyField(m_HotUpdateAssemblies);
|
||||
EditorGUILayout.PropertyField(m_collectAssetReferenceTypes);
|
||||
EditorGUILayout.PropertyField(m_OutputLinkFile);
|
||||
EditorGUILayout.PropertyField(m_OutputAOTGenericReferenceFile);
|
||||
EditorGUILayout.PropertyField(m_MaxGenericReferenceIteration);
|
||||
|
|
|
@ -20,7 +20,10 @@ namespace HybridCLR.Editor
|
|||
[Header("热更新dlls")]
|
||||
public string[] hotUpdateAssemblies;
|
||||
|
||||
[Header("自动扫描生成的link.xml路径")]
|
||||
[Header("生成link.xml时扫描asset中引用的类型")]
|
||||
public bool collectAssetReferenceTypes;
|
||||
|
||||
[Header("生成的link.xml路径")]
|
||||
public string outputLinkFile = "HybridCLRData/Generated/link.xml";
|
||||
|
||||
[Header("自动扫描生成的AOTGenericReferences.cs路径")]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.focus-creative-games.hybridclr_unity",
|
||||
"version": "0.4.4",
|
||||
"version": "0.4.5",
|
||||
"displayName": "HybridCLR",
|
||||
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
|
||||
"category": "Runtime",
|
||||
|
|
Loading…
Reference in New Issue