mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-13 22:39:39 -05:00
add IVRMComponent to VRMLookAtBlendShapeApplyer
This commit is contained in:
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
public class VRMLookAtBlendShapeApplyer : MonoBehaviour
|
||||
public class VRMLookAtBlendShapeApplyer : MonoBehaviour, IVRMComponent
|
||||
{
|
||||
public bool DrawGizmo = true;
|
||||
|
||||
@@ -17,17 +17,21 @@ namespace VRM
|
||||
[SerializeField]
|
||||
public CurveMapper VerticalUp = new CurveMapper(90.0f, 1.0f);
|
||||
|
||||
public void OnImported(VRMImporterContext context)
|
||||
{
|
||||
var gltfFirstPerson = context.VRM.extensions.VRM.firstPerson;
|
||||
Horizontal.Apply(gltfFirstPerson.lookAtHorizontalOuter);
|
||||
VerticalDown.Apply(gltfFirstPerson.lookAtVerticalDown);
|
||||
VerticalUp.Apply(gltfFirstPerson.lookAtVerticalUp);
|
||||
}
|
||||
|
||||
VRMLookAtHead m_head;
|
||||
VRMBlendShapeProxy m_propxy;
|
||||
|
||||
private void Awake()
|
||||
private void Start()
|
||||
{
|
||||
m_head = GetComponent<VRMLookAtHead>();
|
||||
m_propxy = GetComponent<VRMBlendShapeProxy>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (m_head == null)
|
||||
{
|
||||
enabled = false;
|
||||
@@ -36,11 +40,6 @@ namespace VRM
|
||||
m_head.YawPitchChanged += ApplyRotations;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
m_head.YawPitchChanged -= ApplyRotations;
|
||||
}
|
||||
|
||||
void ApplyRotations(float yaw, float pitch)
|
||||
{
|
||||
if (yaw < 0)
|
||||
|
||||
@@ -53,27 +53,18 @@ namespace VRM
|
||||
|
||||
VRMLookAtHead m_head;
|
||||
|
||||
void Update()
|
||||
void Start()
|
||||
{
|
||||
m_head = GetComponent<VRMLookAtHead>();
|
||||
if (m_head == null)
|
||||
{
|
||||
m_head = GetComponent<VRMLookAtHead>();
|
||||
if (m_head == null)
|
||||
{
|
||||
enabled = false;
|
||||
Debug.LogError("[VRMLookAtBoneApplyer]VRMLookAtHead not found");
|
||||
return;
|
||||
}
|
||||
m_head.YawPitchChanged += ApplyRotations;
|
||||
LeftEye.Setup();
|
||||
RightEye.Setup();
|
||||
enabled = false;
|
||||
Debug.LogError("[VRMLookAtBoneApplyer]VRMLookAtHead not found");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
m_head.YawPitchChanged -= ApplyRotations;
|
||||
m_head = null;
|
||||
m_head.YawPitchChanged += ApplyRotations;
|
||||
LeftEye.Setup();
|
||||
RightEye.Setup();
|
||||
}
|
||||
|
||||
#region Gizmo
|
||||
|
||||
@@ -103,9 +103,7 @@ namespace VRM
|
||||
case LookAtType.BlendShape:
|
||||
{
|
||||
var applyer = gameObject.AddComponent<VRMLookAtBlendShapeApplyer>();
|
||||
applyer.Horizontal.Apply(gltfFirstPerson.lookAtHorizontalOuter);
|
||||
applyer.VerticalDown.Apply(gltfFirstPerson.lookAtVerticalDown);
|
||||
applyer.VerticalUp.Apply(gltfFirstPerson.lookAtVerticalUp);
|
||||
applyer.OnImported(context);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user