UniVRM/Assets/UniGLTF/Editor/UniHumanoid/bvhAssetPostprocessor.cs
ousttrue 29545202d3 UniHumanoid のフォルダ構成を整理し、不要になった asmdef を削除した。Resource/test_motion.txt の場所が変更になるのに注意。
* Assets/UniHumanoid/Scripts => Assets/UniGLTF/Runtime/Humanoid
* Assets/UniHumanoid/Editor => Assets/UniGLTF/Editor/Humanoid
* Assets/UniHumanoid/Editor/Tests => Assets/UniGLTF/Tests/Humanoid
* => docs/unihumanoid/index.md
2021-12-06 16:22:25 +09:00

50 lines
1.6 KiB
C#

using System;
using System.IO;
using UnityEditor;
using UnityEngine;
namespace UniHumanoid
{
public class bvhAssetPostprocessor : AssetPostprocessor
{
static bool IsStreamingAsset(string path)
{
var baseFullPath = Path.GetFullPath(Application.dataPath + "/..").Replace("\\", "/");
path = Path.Combine(baseFullPath, path).Replace("\\", "/");
return path.StartsWith(Application.streamingAssetsPath + "/");
}
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
foreach (string path in importedAssets)
{
if (IsStreamingAsset(path))
{
Debug.LogFormat("Skip StreamingAssets: {0}", path);
continue;
}
var ext = Path.GetExtension(path).ToLower();
if (ext == ".bvh")
{
Debug.LogFormat("ImportBvh: {0}", path);
var context = new BvhImporterContext();
try
{
context.Parse(path);
context.Load();
context.SaveAsAsset();
context.Destroy(false);
}
catch(Exception ex)
{
Debug.LogError(ex);
context.Destroy(true);
}
}
}
}
}
}