mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-11 13:04:17 -05:00
50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using System;
|
|
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
|
|
namespace VRM
|
|
{
|
|
public class vrmAssetPostprocessor : AssetPostprocessor
|
|
{
|
|
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
|
|
{
|
|
foreach (string path in importedAssets)
|
|
{
|
|
var ext = Path.GetExtension(path).ToLower();
|
|
if (ext == ".vrm")
|
|
{
|
|
VRMImporterContext context = null;
|
|
try
|
|
{
|
|
context=VRMImporter.LoadFromPath(path);
|
|
|
|
/*
|
|
var prefabPath = String.Format("{0}/{1}.prefab",
|
|
Path.GetDirectoryName(path),
|
|
Path.GetFileNameWithoutExtension(path));
|
|
|
|
VRMAssetWriter.SaveAsPrefab(context.Root, prefabPath);
|
|
|
|
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath.ToUnityRelativePath());
|
|
Selection.activeObject = prefab;
|
|
*/
|
|
|
|
context.SaveAsAsset();
|
|
context.Destroy(false);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
Debug.LogError(ex);
|
|
if (context != null)
|
|
{
|
|
context.Destroy(true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|