Added BlendShapeAvatar.Restore

This commit is contained in:
ousttrue 2018-09-06 15:34:31 +09:00
parent 3091ed4a1d
commit 5238767ca7
2 changed files with 39 additions and 2 deletions

View File

@ -2,7 +2,7 @@
using System.Linq;
using System;
using System.Collections.Generic;
using UniGLTF;
namespace VRM
{
@ -12,6 +12,33 @@ namespace VRM
[SerializeField]
public List<BlendShapeClip> Clips = new List<BlendShapeClip>();
#if UNITY_EDITOR
[ContextMenu("Restore")]
void Restore()
{
var assetPath = UnityPath.FromAsset(this);
if (assetPath.IsNull)
{
return;
}
foreach(var x in assetPath.Parent.ChildFiles)
{
var clip = UnityEditor.AssetDatabase.LoadAssetAtPath<BlendShapeClip>(x.Value);
if (clip == null) continue;
if (!Clips.Contains(clip))
{
Clips.Add(clip);
}
Debug.LogFormat("{0}", clip.name);
}
Clips = Clips.OrderBy(x => BlendShapeKey.CreateFrom(x)).ToList();
}
#endif
/// <summary>
/// Unknown以外で存在しないものを全て作る
/// </summary>

View File

@ -4,7 +4,7 @@
namespace VRM
{
[Serializable]
public struct BlendShapeKey : IEquatable<BlendShapeKey>
public struct BlendShapeKey : IEquatable<BlendShapeKey>, IComparable<BlendShapeKey>
{
public string Name;
public BlendShapePreset Preset;
@ -91,5 +91,15 @@ namespace VRM
{
return this.Equals(CreateFrom(clip));
}
public int CompareTo(BlendShapeKey other)
{
if (Preset != other.Preset)
{
return Preset - other.Preset;
}
return 0;
}
}
}