add VRM scripts

This commit is contained in:
ousttrue
2018-03-27 16:40:11 +09:00
parent 77b59c75d7
commit 2b34694ab3
158 changed files with 10771 additions and 0 deletions

View 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);
}
}
}
}
}
}
}