Open rrtt2323 opened 1 year ago
这里显示ini文件对CS脚本文件有依赖关系。我本地复现看看
有依赖的原因是我对.ini文件做了编辑器扩展,在资源导入时,给转换成 ScriptableObject 那种序列化文件了,所以会有依赖了。 原则上任意后缀名的文本资源都能这么扩展,所以最好是排除一下有对.cs文件依赖的。
`[UnityEditor.AssetImporters.ScriptedImporter(1, "ini")] public class IniFileImporter : UnityEditor.AssetImporters.ScriptedImporter { public string filePath;
public override void OnImportAsset(UnityEditor.AssetImporters.AssetImportContext ctx)
{
filePath = ctx.assetPath;
// 读取文件
var textContent = File.ReadAllText(filePath);
// 序列化文件
var iniObject = IniFileAsset.ParseIniContent(textContent);
// 把对象设置给编辑器
ctx.AddObjectToAsset(nameof(IniFileAsset), iniObject);
ctx.SetMainObject(iniObject);
}
}`
核心代码就是这样
如果是这样的话,ScriptableObject序列化的文件是不能作为原生文件的。
如果只是ini格式的纯文本,作为原生文件是没任何问题的。
如果只是ini格式的纯文本,作为原生文件是没任何问题的。
是纯文本的,只是在导入时序列化到内存里,也不产生实体的.asset文件
明白了。1.4.10版本已经注释了相关代码,你可以试一下。该问题请不要关闭。
如图,因为我有一个对.ini文件的扩展功能,所以这里依赖不会为0,就无法被收集了,所以我把这里的代码修改了一下,大佬看看是不是合并一下。
AssetBundleCollector.cs 263 行处
`// 注意:原生文件只支持无依赖关系的资源 string[] depends = AssetDatabase.GetDependencies(assetPath, true); if (depends.Length != 1) { // 检查依赖的是不是代码 bool dependCode = true; foreach (var item in depends) { // 排除资源本身 if(item == assetPath) continue;