今天开发过程中遇到一个报错:”The asset at … has been scheduled for reimport during the Refresh loop…”,报错的资源有.ttf字体文件,也有.prefab预制体。搜索了好久,看到有人说删除Library文件夹后重开编辑器可以解决,但我试过后还是会报错,最后顺着可能的思路自己解决了。
如果你在构建、切换平台时也遇到了同样的报错,并且重新生成Library文件夹后可以尝试一下这个方法:
using UnityEngine; using UnityEditor; using System.IO; public class AssetFix { [MenuItem("测试/资源修复")] public static void ReserializeAssets() { //1.找到这些报错的文件 var lFiles = Directory.GetFiles("Assets/Resources/Fonts", "*.*", SearchOption.AllDirectories); //2.重新序列化 AssetDatabase.ForceReserializeAssets(lFiles, ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata); AssetDatabase.Refresh(); } }
作者:7_erQ https://www.bilibili.com/read/cv24998325/ 出处:bilibili