在Unity3D中创建自定义导入程序时如何避免项目视图中的两个文件?

Sov*_*iut 30 assets unity-game-engine

注意:我的网络比Unity Answers更宽,我的原始问题可以在这里找到.

我创建了一个ProTools CueSheet导入程序.它用于OnPostprocessAllAssets()检测项目中具有.cuesheet扩展名的文件.然后它通过我的解析器运行那些cuesheet文件.这会生成一个ScriptableObject,然后通过它转换为资产Database.CreateAsset().

问题是,这给我留下了两个文件,原始cuesheet和新生成的资产.有没有什么方法可以生成资源,例如原始cuesheet充当资产,就像纹理或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();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Sri*_*ala 1

PropertyDrawer我将为该类创建一个SerializableCueSheet以便它接受文件.cueSheet TextAsset或路径.cueSheet并创建该类的实例CueSheet并分配或修改它。