mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-12 13:59:21 -05:00
Merge pull request #975 from ousttrue/fix10/fix_expression_editor
Fix10/fix expression editor
This commit is contained in:
@@ -83,34 +83,7 @@ namespace UniVRM10
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual GameObject GetPrefab()
|
||||
{
|
||||
var assetPath = AssetDatabase.GetAssetPath(target);
|
||||
if (string.IsNullOrEmpty(assetPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var mainObject = AssetDatabase.LoadMainAssetAtPath(assetPath);
|
||||
if (mainObject != null)
|
||||
{
|
||||
//return mainObject;
|
||||
}
|
||||
|
||||
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
|
||||
if (prefab != null) return prefab;
|
||||
|
||||
var parent = UnityPath.FromUnityPath(assetPath).Parent;
|
||||
var prefabPath = parent.Parent.Child(parent.FileNameWithoutExtension + ".prefab");
|
||||
prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath.Value);
|
||||
if (prefab != null) return prefab;
|
||||
|
||||
var parentParent = UnityPath.FromUnityPath(assetPath).Parent.Parent;
|
||||
var vrmPath = parent.Parent.Child(parent.FileNameWithoutExtension + ".vrm");
|
||||
prefab = UnityEditor.AssetDatabase.LoadAssetAtPath<GameObject>(vrmPath.Value);
|
||||
|
||||
return prefab;
|
||||
}
|
||||
protected abstract GameObject GetPrefab();
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
@@ -126,10 +99,6 @@ namespace UniVRM10
|
||||
m_renderer.Dispose();
|
||||
m_renderer = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
if (m_scene != null)
|
||||
{
|
||||
//Debug.LogFormat("OnDestroy");
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
@@ -23,6 +24,11 @@ namespace UniVRM10
|
||||
}
|
||||
}
|
||||
|
||||
protected override GameObject GetPrefab()
|
||||
{
|
||||
return PrefabUtility.GetCorrespondingObjectFromSource(target as VRM10ExpressionAvatar)?.gameObject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 選択中の Expression のエディタ
|
||||
/// </summary>
|
||||
|
||||
@@ -45,9 +45,8 @@ namespace UniVRM10
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: BlendShape
|
||||
}
|
||||
|
||||
dst.name = src.Name;
|
||||
dst.vertices = positions.ToArray();
|
||||
dst.normals = normals.ToArray();
|
||||
@@ -80,6 +79,25 @@ namespace UniVRM10
|
||||
|
||||
dst.RecalculateBounds();
|
||||
dst.RecalculateTangents();
|
||||
|
||||
//
|
||||
// blendshape
|
||||
//
|
||||
var blendShapeCount = src.Meshes[0].MorphTargets.Count;
|
||||
for (int i = 0; i < blendShapeCount; ++i)
|
||||
{
|
||||
positions.Clear();
|
||||
normals.Clear();
|
||||
var name = src.Meshes[0].MorphTargets[i].Name;
|
||||
for (int meshIndex = 0; meshIndex < src.Meshes.Count; ++meshIndex)
|
||||
{
|
||||
var morphTarget = src.Meshes[meshIndex].MorphTargets[i];
|
||||
positions.AddRange(morphTarget.VertexBuffer.Positions.GetSpan<Vector3>());
|
||||
normals.AddRange(morphTarget.VertexBuffer.Normals.GetSpan<Vector3>());
|
||||
}
|
||||
dst.AddBlendShapeFrame(name, 100.0f, positions.ToArray(), normals.ToArray(), null);
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user