Commit 4c75d371 authored by 杨泽宇's avatar 杨泽宇

更新迷宫第一层

parent f2bfc70a
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -43,7 +43,7 @@ public class GrabRayController : MonoBehaviour
EnableAction(teleportActivateReference);
EnableAction(moveReference);
EnableAction(turnReference);
DisableAction(rotateAnchorReference);
//DisableAction(rotateAnchorReference);
DisableAction(translateAnchorReference);
}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
/// <summary>
/// 操作管理器
/// </summary>
public class OperationManager : MonoBehaviour
{
[SerializeField]
[Tooltip("惯用手是否是右手(默认右手为惯用手)")]
private bool IsRight=true;
[SerializeField]
private XRControllerManager LeftHandManager;
[SerializeField]
private XRControllerManager RightHandManager;
[SerializeField]
private ActionBasedSnapTurnProvider snapTurnProvider;
[SerializeField]
private ActionBasedContinuousTurnProvider smoothTurnProvider;
[Tooltip("惯用手")]
private XRControllerManager Handedness;
/// <summary>
/// 设置惯用手
/// </summary>
public void SetHandedness(bool RightHand)
{
Handedness = RightHand ? RightHandManager : LeftHandManager;
Handedness.SetHandedness();
}
public void SetTurnStyle(bool SmoothTurnEnabled)
{
Handedness.smoothTurnEnabled = SmoothTurnEnabled;
}
public void SetMoveScheme(bool SmoothMotionEnabled)
{
Handedness.smoothMotionEnabled = SmoothMotionEnabled;
}
}
fileFormatVersion: 2
guid: 7bebc863f82f009409f034494e2f870e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 操作设置
/// </summary>
public class OperationSettings : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: 969b4a0716e4c4840b61d674bee89b00
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.XR.Interaction.Toolkit;
public class XRControllerManager : MonoBehaviour
{
[Space]
[Header("交互程序")]
[SerializeField]
private XRInteractionGroup m_ManipulationInteractionGroup;
[SerializeField]
[Tooltip("抓取物体的射线")]
private XRRayInteractor grabRayInteractor;
[SerializeField]
[Tooltip("抓取物体")]
private XRDirectInteractor grabDirectInteractor;
[SerializeField]
[Tooltip("抓取时候的判断")]
private GrabRayController grabRayController;
[Space]
[Header("Actions")]
[SerializeField]
[Tooltip("旋转")]
private InputActionReference turnReference;
[SerializeField]
[Tooltip("一定角度旋转")]
private InputActionReference SnapTurnReference;
[SerializeField]
[Tooltip("摇杆移动")]
private InputActionReference MoveReference;
[SerializeField]
[Tooltip("传送")]
private InputActionReference TeleportModeActivateReference;
[SerializeField]
private InputActionReference TeleportModeCancelReference;
[SerializeField]
public InputActionReference rotateAnchorReference;
[SerializeField]
public InputActionReference translateAnchorReference;
[Space]
[Header("设置")]
[SerializeField]
[Tooltip("如果为true,将启用连续移动。如果为false,将启用传送。")]
private bool SmoothMotionEnabled;
[SerializeField]
[Tooltip("如果为true,将启用连续转弯。如果为false,将启用快速转弯。")]
private bool SmoothTurnEnabled;
[Tooltip("是否是惯用手")]
private bool isHandedness=false;
private void Start()
{
DisableLocomotionActions();
grabRayInteractor.selectEntered.AddListener(OnEnterGrab);
grabRayInteractor.selectExited.AddListener(OnExitGrab);
}
private void OnDestroy()
{
grabRayInteractor.selectEntered.RemoveListener(OnEnterGrab);
grabRayInteractor.selectExited.RemoveListener(OnExitGrab);
}
private void OnEnterGrab(SelectEnterEventArgs arg)
{
if (isHandedness == true)
{
DisableLocomotionActions();
EnableAction(rotateAnchorReference);
EnableAction(translateAnchorReference);
}
}
private void OnExitGrab(SelectExitEventArgs arg)
{
if (isHandedness == true)
{
DisableAction(rotateAnchorReference);
DisableAction(translateAnchorReference);
UpdateMoveActions();
UpdateTurnActions();
}
}
public void SetHandedness()
{
isHandedness = true;
}
public bool smoothTurnEnabled
{
get => SmoothTurnEnabled;
set
{
SmoothTurnEnabled = value;
UpdateTurnActions();
}
}
public bool smoothMotionEnabled
{
get => SmoothMotionEnabled;
set
{
SmoothMotionEnabled = value;
UpdateMoveActions();
}
}
private void UpdateTurnActions()
{
SetEnabled(turnReference, SmoothTurnEnabled);
SetEnabled(SnapTurnReference, !SmoothTurnEnabled);
}
private void UpdateMoveActions()
{
SetEnabled(MoveReference, SmoothMotionEnabled);
SetEnabled(TeleportModeActivateReference, !SmoothMotionEnabled);
SetEnabled(TeleportModeCancelReference, !SmoothMotionEnabled);
}
private void DisableLocomotionActions()
{
DisableAction(turnReference);
DisableAction(SnapTurnReference);
DisableAction(MoveReference);
DisableAction(TeleportModeActivateReference);
DisableAction(TeleportModeCancelReference);
}
/// <summary>
/// 设置Action的打开和关闭
/// </summary>
/// <param name="actionReference"></param>
/// <param name="enabled"></param>
private void SetEnabled(InputActionReference actionReference,bool enabled)
{
if (enabled)
EnableAction(actionReference);
else
DisableAction(actionReference);
}
/// <summary>
/// 打开Action
/// </summary>
/// <param name="actionReference"></param>
private void EnableAction(InputActionReference actionReference)
{
var action = GetInputAction(actionReference);
if (action != null && !action.enabled)
action.Enable();
}
/// <summary>
/// 关闭Action
/// </summary>
/// <param name="actionReference"></param>
private void DisableAction(InputActionReference actionReference)
{
var action = GetInputAction(actionReference);
if (action != null && action.enabled)
action.Disable();
}
/// <summary>
/// 获取Action
/// </summary>
/// <param name="actionReference"></param>
/// <returns></returns>
private InputAction GetInputAction(InputActionReference actionReference)
{
return actionReference != null ? actionReference.action : null;
}
}
fileFormatVersion: 2
guid: b6169cac973668d408b6d8fa1d60f3ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -14,8 +14,8 @@ RenderTexture:
m_DownscaleFallback: 0
m_IsAlphaChannelOptional: 0
serializedVersion: 5
m_Width: 600
m_Height: 600
m_Width: 1000
m_Height: 1000
m_AntiAliasing: 1
m_MipCount: -1
m_DepthStencilFormat: 94
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment