Move BlendShapeAvatar.AddBlendShapeClip

This commit is contained in:
ousttrue
2018-11-02 14:18:43 +09:00
parent 411bd286df
commit 79e9241ef7
2 changed files with 30 additions and 25 deletions

View File

@@ -3,6 +3,10 @@ using System.Linq;
using System;
using System.Collections.Generic;
using UniGLTF;
using System.IO;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace VRM
{
@@ -37,6 +41,31 @@ namespace VRM
}
Clips = Clips.OrderBy(x => BlendShapeKey.CreateFrom(x)).ToList();
}
public void AddBlendShapeClip()
{
var dir = Path.GetDirectoryName(AssetDatabase.GetAssetPath(this));
var path = EditorUtility.SaveFilePanel(
"Create BlendShapeClip",
dir,
string.Format("BlendShapeClip#{0}.asset", Clips.Count),
"asset");
if (string.IsNullOrEmpty(path))
{
return;
}
path = path.ToUnityRelativePath();
//Debug.LogFormat("{0}", path);
var clip = ScriptableObject.CreateInstance<BlendShapeClip>();
clip.BlendShapeName = Path.GetFileNameWithoutExtension(path);
clip.Prefab = AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GetAssetPath(this));
AssetDatabase.CreateAsset(clip, path);
AssetDatabase.ImportAsset(path);
Clips.Add(clip);
EditorUtility.SetDirty(this);
AssetDatabase.SaveAssets();
}
#endif
/// <summary>

View File

@@ -16,30 +16,6 @@ namespace VRM
.Select(x => x.ToString()).ToArray();
BlendShapeAvatar m_target;
void AddBlendShapeClip()
{
var dir = Path.GetDirectoryName(AssetDatabase.GetAssetPath(m_target));
var path = EditorUtility.SaveFilePanel(
"Create BlendShapeClip",
dir,
string.Format("BlendShapeClip#{0}.asset", m_target.Clips.Count),
"asset");
if (string.IsNullOrEmpty(path))
{
return;
}
path = path.ToUnityRelativePath();
//Debug.LogFormat("{0}", path);
var clip = ScriptableObject.CreateInstance<BlendShapeClip>();
clip.BlendShapeName = Path.GetFileNameWithoutExtension(path);
clip.Prefab = AssetDatabase.LoadAssetAtPath<GameObject>(AssetDatabase.GetAssetPath(m_target));
AssetDatabase.CreateAsset(clip, path);
AssetDatabase.ImportAsset(path);
m_target.Clips.Add(clip);
EditorUtility.SetDirty(m_target);
AssetDatabase.SaveAssets();
}
BlendShapeClip m_currentClip;
BlendShapeClip CurrentClip
@@ -119,7 +95,7 @@ namespace VRM
// Add
if (GUILayout.Button("Add BlendShapeClip"))
{
AddBlendShapeClip();
m_target.AddBlendShapeClip();
}
if (CurrentClip != null)