AssetDatabase.ForceReserializeAssets

Switch to Manual
public static void ForceReserializeAssets ();

Parameters

assetPaths应该重新序列化的资源的路径。如果省略该属性,系统将重新序列化项目中的所有资源。
options指定是重新序列化资源本身,还是它们的 .meta 文件,亦或者是重新序列化这两者。如果省略该属性,则默认重新序列化这两者。

Description

强制加载给定资源并将其重新序列化,这样会将所有待定数据更改都刷新到磁盘。

When Unity loads old data from an asset or Scene file, the data is dynamically upgraded in memory, but not written back to disk unless the user does something that explicitly dirties the object (like changing a value on it). This method allows you to proactively load, upgrade, and write back to disk any asset or Scene files in the project, without having to manually make them dirty.

Unity 的常规行为有许多优势,尤其适用于带有版本控制系统的项目,此类项目迁移到一个新的 Unity 版本后,会主动升级所有资源,这会导致提交大量更改的文件列表。然而缺点是,当用户继续处理项目时,升级内容会与刻意更改的内容混合在一起。借助该方法,您能够以一种可控方式主动准确地确定要升级的资源以及升级时间。