2026-06-17 스타터킷,툰셰이더,오른손

This commit is contained in:
2026-06-17 10:51:49 +09:00
parent 48c3cfe9f1
commit 6ccae390f6
2067 changed files with 115278 additions and 697 deletions

View File

@@ -1,14 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using Unity.XR.CoreUtils.Bindings;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Serialization;
using UnityEngine.XR.Interaction.Toolkit.Attachment;
using UnityEngine.XR.Interaction.Toolkit.Inputs.Readers;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.XR.Interaction.Toolkit.Interactors;
using UnityEngine.XR.Interaction.Toolkit.UI;
namespace UnityEngine.XR.Interaction.Toolkit.Samples.StarterAssets
namespace XR.Interaction.Toolkit.Samples
{
/// <summary>
/// Use this class to mediate the interactors for a controller under different interaction states
@@ -26,7 +27,7 @@ namespace UnityEngine.XR.Interaction.Toolkit.Samples.StarterAssets
/// with the Direct Interactor taking priority over the Ray Interactor.
/// </remarks>
[AddComponentMenu("XR/Controller Input Action Manager")]
public class ControllerInputActionManager : MonoBehaviour
public class ControllerInputActionManager : MonoBehaviour, IEnumerable
{
[Space]
[Header("Interactors")]
@@ -132,7 +133,6 @@ public bool uiScrollingEnabled
bool m_StartCalled;
bool m_PostponedDeactivateTeleport;
bool m_PostponedNearRegionLocomotion;
bool m_HoveringScrollableUI;
readonly HashSet<InputAction> m_LocomotionUsers = new HashSet<InputAction>();
@@ -280,6 +280,15 @@ void OnCancelTeleport(InputAction.CallbackContext context)
m_RayInteractorChanged?.Invoke(m_RayInteractor);
}
void OnNearFarSelectionRegionChanged(NearFarInteractor.Region selectionRegion)
{
if (selectionRegion == NearFarInteractor.Region.Far ||
(selectionRegion == NearFarInteractor.Region.Near && !m_NearFarEnableTeleportDuringNearInteraction))
DisableTeleportActions();
else
UpdateLocomotionActions();
}
void OnStartLocomotion(InputAction.CallbackContext context)
{
m_LocomotionUsers.Add(context.action);
@@ -296,52 +305,6 @@ void OnStopLocomotion(InputAction.CallbackContext context)
}
}
void OnNearFarSelectionRegionChanged(NearFarInteractor.Region selectionRegion)
{
m_PostponedNearRegionLocomotion = false;
if (selectionRegion == NearFarInteractor.Region.None)
{
UpdateLocomotionActions();
return;
}
var manipulateAttachTransform = false;
var attachController = m_NearFarInteractor.interactionAttachController as InteractionAttachController;
if (attachController != null)
{
manipulateAttachTransform = attachController.useManipulationInput &&
(attachController.manipulationInput.inputSourceMode == XRInputValueReader.InputSourceMode.InputActionReference && attachController.manipulationInput.inputActionReference != null) ||
(attachController.manipulationInput.inputSourceMode != XRInputValueReader.InputSourceMode.InputActionReference && attachController.manipulationInput.inputSourceMode != XRInputValueReader.InputSourceMode.Unused);
}
if (selectionRegion == NearFarInteractor.Region.Far)
{
if (manipulateAttachTransform)
DisableAllLocomotionActions();
else
DisableTeleportActions();
}
else if (selectionRegion == NearFarInteractor.Region.Near)
{
// Determine if the user entered the near region due to pulling back on the thumbstick.
// If so, postpone enabling locomotion until the user releases the thumbstick
// in order to avoid an immediate snap turn around from triggering on region change.
var hasStickInput = manipulateAttachTransform && HasStickInput(attachController);
if (hasStickInput)
{
m_PostponedNearRegionLocomotion = true;
DisableAllLocomotionActions();
}
else
{
UpdateLocomotionActions();
if (!m_NearFarEnableTeleportDuringNearInteraction)
DisableTeleportActions();
}
}
}
void OnRaySelectEntered(SelectEnterEventArgs args)
{
if (m_RayInteractor.manipulateAttachTransform)
@@ -421,6 +384,7 @@ protected void Start()
protected void Update()
{
// Start the coroutine that executes code after the Update phase (during yield null).
// Since this behavior has the default execution order, it runs after the XRInteractionManager,
// so selection events have been finished by now this frame. This means that the teleport interactor
// has had a chance to process its select interaction event and teleport if needed.
@@ -431,28 +395,6 @@ protected void Update()
m_PostponedDeactivateTeleport = false;
}
// If stick input caused the near region to be entered,
// wait until the stick is released before enabling locomotion.
if (m_PostponedNearRegionLocomotion)
{
var hasStickInput = false;
if (m_NearFarInteractor != null &&
m_NearFarInteractor.interactionAttachController is InteractionAttachController attachController
&& attachController != null)
{
hasStickInput = HasStickInput(attachController);
}
if (!hasStickInput)
{
m_PostponedNearRegionLocomotion = false;
UpdateLocomotionActions();
if (!m_NearFarEnableTeleportDuringNearInteraction)
DisableTeleportActions();
}
}
}
void UpdateLocomotionActions()
@@ -491,15 +433,6 @@ void UpdateUIActions()
SetEnabled(m_UIScroll, m_UIScrollingEnabled && m_HoveringScrollableUI && m_LocomotionUsers.Count == 0);
}
static bool HasStickInput(InteractionAttachController attachController)
{
// 75% of default 0.5 press threshold
const float sqrStickReleaseThreshold = 0.375f * 0.375f;
return attachController.manipulationInput.TryReadValue(out var stickInput) &&
stickInput.sqrMagnitude > sqrStickReleaseThreshold;
}
static void SetEnabled(InputActionReference actionReference, bool enabled)
{
if (enabled)
@@ -511,13 +444,15 @@ static void SetEnabled(InputActionReference actionReference, bool enabled)
static void EnableAction(InputActionReference actionReference)
{
var action = GetInputAction(actionReference);
action?.Enable();
if (action != null && !action.enabled)
action.Enable();
}
static void DisableAction(InputActionReference actionReference)
{
var action = GetInputAction(actionReference);
action?.Disable();
if (action != null && action.enabled)
action.Disable();
}
static InputAction GetInputAction(InputActionReference actionReference)
@@ -526,5 +461,10 @@ static InputAction GetInputAction(InputActionReference actionReference)
return actionReference != null ? actionReference.action : null;
#pragma warning restore IDE0031
}
public IEnumerator GetEnumerator()
{
throw new System.NotImplementedException();
}
}
}