mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-25 03:55:52 -05:00
Move BlendShapeAvatar.AddBlendShapeClip
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user