diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10Loaded.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10Loaded.cs index b607a673f..9f3cf4377 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10Loaded.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10Loaded.cs @@ -57,7 +57,7 @@ namespace UniVRM10.VRM10Viewer } } - public Loaded(RuntimeGltfInstance instance, Transform lookAtTarget) + public Loaded(RuntimeGltfInstance instance) { m_instance = instance; @@ -70,9 +70,6 @@ namespace UniVRM10.VRM10Viewer m_lipSync = instance.gameObject.AddComponent(); m_blink = instance.gameObject.AddComponent(); m_autoExpression = instance.gameObject.AddComponent(); - - m_controller.LookAtTargetType = VRM10ObjectLookAt.LookAtTargetTypes.SpecifiedTransform; - m_controller.LookAtTarget = lookAtTarget; } } diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity b/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity index 9956a7734..8bbd22643 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10Viewer.unity @@ -27458,7 +27458,6 @@ MonoBehaviour: m_pastePose: {fileID: 1307084564} m_showBoxMan: {fileID: 1767706908} m_useAsync: {fileID: 602093299} - m_target: {fileID: 802105000} m_motion: {fileID: 4900000, guid: 08df5151e71aed748b13547492fb8b9a, type: 3} m_useSpringboneSingelton: {fileID: 522109225} m_springbonePause: {fileID: 1728528389} @@ -27502,7 +27501,8 @@ MonoBehaviour: m_lipOh: {fileID: 601334856} m_enableAutoBlink: {fileID: 634488422} m_blink: {fileID: 223244499} - m_lookAtTarget: {fileID: 619400621} + m_lookAtTarget: {fileID: 802105000} + m_useLookAtTarget: {fileID: 619400621} m_yaw: {fileID: 833614002} m_pitch: {fileID: 374061190} m_texts: diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs index ff1a11607..c2fcfdbeb 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs @@ -14,7 +14,6 @@ namespace UniVRM10.VRM10Viewer { [SerializeField] GameObject Root = default; - [SerializeField] Text m_version = default; @@ -34,9 +33,6 @@ namespace UniVRM10.VRM10Viewer [SerializeField] Toggle m_useAsync = default; - [SerializeField] - GameObject m_target = default; - [SerializeField] TextAsset m_motion; @@ -106,7 +102,9 @@ namespace UniVRM10.VRM10Viewer Slider m_blink = default; [SerializeField] - Toggle m_lookAtTarget = default; + GameObject m_lookAtTarget = default; + [SerializeField] + Toggle m_useLookAtTarget = default; [SerializeField] Slider m_yaw = default; [SerializeField] @@ -345,14 +343,14 @@ namespace UniVRM10.VRM10Viewer m_enableAutoBlink = map.Get("EnableAutoBlink"); m_blink = map.Get("SliderBlink"); - m_lookAtTarget = map.Get("UseLookAtTarget"); + m_useLookAtTarget = map.Get("UseLookAtTarget"); m_yaw = map.Get("SliderYaw"); m_pitch = map.Get("SliderPitch"); #if UNITY_2022_3_OR_NEWER m_target = GameObject.FindFirstObjectByType().gameObject; #else - m_target = GameObject.FindObjectOfType().gameObject; + m_lookAtTarget = GameObject.FindObjectOfType().gameObject; #endif } @@ -489,6 +487,21 @@ namespace UniVRM10.VRM10Viewer SupportsScalingAtRuntime = m_springboneScaling.isOn, }); } + + if (m_useLookAtTarget.isOn) + { + m_loaded.Instance.LookAtTargetType = VRM10ObjectLookAt.LookAtTargetTypes.SpecifiedTransform; + m_loaded.Instance.LookAtTarget = m_lookAtTarget.transform; + m_yaw.interactable = false; + m_pitch.interactable = false; + } + else + { + m_loaded.Instance.LookAtTargetType = VRM10ObjectLookAt.LookAtTargetTypes.YawPitchValue; + m_loaded.Instance.Runtime.LookAt.SetYawPitchManually(m_yaw.value, m_pitch.value); + m_yaw.interactable = true; + m_pitch.interactable = true; + } } } @@ -647,7 +660,7 @@ namespace UniVRM10.VRM10Viewer var instance = vrm10Instance.GetComponent(); instance.ShowMeshes(); instance.EnableUpdateWhenOffscreen(); - m_loaded = new Loaded(instance, m_target.transform); + m_loaded = new Loaded(instance); m_showBoxMan.isOn = false; } catch (Exception ex)