mirror of
https://udrimavric.com/MAVRIC/Stratasys-450mc-VR.git
synced 2025-01-23 23:58:36 -05:00
37 lines
1011 B
C#
37 lines
1011 B
C#
using UnityEngine.UI;
|
|
using UnityEngine.XR.Interaction.Toolkit;
|
|
|
|
namespace UnityEngine.XR.Content.Interaction
|
|
{
|
|
public class DistanceCalculationToggle : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
Toggle m_Toggle;
|
|
|
|
[SerializeField]
|
|
XRBaseInteractable[] m_Interactables;
|
|
|
|
void Start()
|
|
{
|
|
if (m_Toggle == null)
|
|
return;
|
|
|
|
OnToggleValueChanged(m_Toggle.isOn);
|
|
m_Toggle.onValueChanged.AddListener(OnToggleValueChanged);
|
|
}
|
|
|
|
void OnToggleValueChanged(bool value)
|
|
{
|
|
var distanceCalculationMode = value
|
|
? XRBaseInteractable.DistanceCalculationMode.ColliderVolume
|
|
: XRBaseInteractable.DistanceCalculationMode.ColliderPosition;
|
|
|
|
foreach (var interactable in m_Interactables)
|
|
{
|
|
if (interactable != null)
|
|
interactable.distanceCalculationMode = distanceCalculationMode;
|
|
}
|
|
}
|
|
}
|
|
}
|