mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-09 12:29:23 -05:00
add VRM scripts
This commit is contained in:
49
Scripts/Format/Editor/vrmAssetPostprocessor.cs
Normal file
49
Scripts/Format/Editor/vrmAssetPostprocessor.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user