注意: 我正在扩大范围以涵盖Unity Answers之外的内容,我原始问题的链接在这里。
我创建了一个ProTools CueSheet导入器。它使用OnPostprocessAllAssets()
检测项目中具有.cuesheet
扩展名的文件。然后将这些cue sheet文件通过我的解析器运行。这将生成一个ScriptableObject,随后通过Database.CreateAsset()
转换为资源。
问题是,这会让我得到两个文件,原始cue sheet和新生成的资源。是否有任何方法可以以这样的方式生成资源,即原始cue sheet像纹理或FBX文件一样充当资源?
public class CueSheetPostProcessor : AssetPostprocessor {
static string extension = ".cuesheet";
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) {
foreach (string assetPath in importedAssets) {
if (assetPath.EndsWith(extension, StringComparison.OrdinalIgnoreCase)) {
string newPath = assetPath + ".asset";
Session session = CueImporter.Load(assetPath);
AssetDatabase.CreateAsset(session, newPath);
AssetDatabase.SaveAssets();
}
}
}
}