NOTE: 我投出的网络比Unity Answers更宽,我的原始问题可以找到here .
我创建了一个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();
}
}
}
}
2 回答
我会为
Serializable
类CueSheet
创建PropertyDrawer
,以便它接受.cueSheet TextAsset
或.cueSheet
文件的路径,并创建类CueSheet
的实例并分配或修改它 .您是否尝试过使用AssetDatabase.AddObjectToAsset而不是创建新资产?资产中的文件可以“保留”多个资产和多种资产类型 . 导入.fbx时,项目检查器中的输出有几个:GameObject树(即预制件),某些模型,可能是装备等等 . 所有这些都包含在已处理的.fbx中