提交交互替换
This commit is contained in:
33
Assets/YOMOV Access/Scripts/QuadCatchCtr.cs
Normal file
33
Assets/YOMOV Access/Scripts/QuadCatchCtr.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using BigSpace.XRCore.Event;
|
||||
using BigSpace.Logic;
|
||||
public class QuadCatchCtr : MonoBehaviour
|
||||
{
|
||||
private UnityEngine.XR.Interaction.Toolkit.Interactors.XRRayInteractor rayInteractor;
|
||||
|
||||
void Start()
|
||||
{
|
||||
rayInteractor = GetComponent<UnityEngine.XR.Interaction.Toolkit.Interactors.XRRayInteractor>();
|
||||
rayInteractor.selectEntered.AddListener(OnSelectEntered);
|
||||
rayInteractor.selectExited.AddListener(OnSelectExited);
|
||||
}
|
||||
|
||||
// 握拳时射线命中 Quad → 抓到了
|
||||
void OnSelectEntered(SelectEnterEventArgs args)
|
||||
{
|
||||
string name = args.interactableObject.transform.gameObject.name;
|
||||
if (name.Length >= 4 && name.Substring(0, 4) == "Quad")
|
||||
{
|
||||
int fontIndex = int.Parse(name.Substring(4));
|
||||
// 替换成新 SDK 的事件派发
|
||||
GlobalEventMgr.Dispatch(GameEvent.EventRayQuadOk, true, 2, fontIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// 松手
|
||||
void OnSelectExited(SelectExitEventArgs args)
|
||||
{
|
||||
GlobalEventMgr.Dispatch(GameEvent.EventHandRelease, 2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user