Files
2026-02-21 16:45:37 +08:00

66 lines
1.3 KiB
C#

using UnityEngine;
using UnityEngine.UI;
namespace OculusSampleFramework
{
public class DistanceGrabberSample : MonoBehaviour
{
private bool museSpherecast;
private bool allowGrabThroughWalls;
[SerializeField]
private DistanceGrabber[] m_grabbers;
public bool UseSpherecast
{
get
{
return museSpherecast;
}
set
{
museSpherecast = value;
for (int i = 0; i < m_grabbers.Length; i++)
{
m_grabbers[i].UseSpherecast = museSpherecast;
}
}
}
public bool AllowGrabThroughWalls
{
get
{
return allowGrabThroughWalls;
}
set
{
allowGrabThroughWalls = value;
for (int i = 0; i < m_grabbers.Length; i++)
{
m_grabbers[i].m_preventGrabThroughWalls = !allowGrabThroughWalls;
}
}
}
private void Start()
{
DebugUIBuilder.instance.AddLabel("Distance Grab Sample");
DebugUIBuilder.instance.AddToggle("Use Spherecasting", ToggleSphereCasting, museSpherecast);
DebugUIBuilder.instance.AddToggle("Grab Through Walls", ToggleGrabThroughWalls, allowGrabThroughWalls);
DebugUIBuilder.instance.Show();
}
public void ToggleSphereCasting(Toggle t)
{
UseSpherecast = !UseSpherecast;
}
public void ToggleGrabThroughWalls(Toggle t)
{
AllowGrabThroughWalls = !AllowGrabThroughWalls;
}
}
}