mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-11 21:14:19 -05:00
Added BlendShapeAvatar.Restore
This commit is contained in:
parent
3091ed4a1d
commit
5238767ca7
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user