142 lines
3.7 KiB
C#
142 lines
3.7 KiB
C#
using Microsoft.MixedReality.Toolkit.Input;
|
|
using Microsoft.MixedReality.Toolkit.UI;
|
|
using Microsoft.MixedReality.Toolkit.Utilities;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Device : MonoBehaviour, IMixedRealityTouchHandler, IMixedRealityInputHandler, IMixedRealityFocusHandler
|
|
{
|
|
private MeshOutline meshOutline;
|
|
[HideInInspector]
|
|
/// <summary>
|
|
/// 是否完成
|
|
/// </summary>
|
|
public bool isCompleted;
|
|
[HideInInspector]
|
|
/// <summary>
|
|
/// 初始位置
|
|
/// </summary>
|
|
public Vector3 initialPos;
|
|
[HideInInspector]
|
|
public Vector3 initialRot;
|
|
|
|
public static List<Device> devices = new List<Device>();
|
|
private void Awake()
|
|
{
|
|
initialPos = transform.localPosition;
|
|
initialRot = transform.localEulerAngles;
|
|
}
|
|
// Start is called before the first frame update
|
|
public virtual void Start()
|
|
{
|
|
devices.Add(this);
|
|
Init();
|
|
MiddleInit();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
public virtual void Init()
|
|
{
|
|
transform.localEulerAngles = initialRot;
|
|
transform.localPosition = initialPos;
|
|
}
|
|
/// <summary>
|
|
/// 重进房间初始化
|
|
/// </summary>
|
|
public virtual void MiddleInit()
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击物体按下
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnInputDown(InputEventData eventData)
|
|
{
|
|
//Debug.Log("OnInputDown");
|
|
}
|
|
/// <summary>
|
|
/// 点击物体抬起
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnInputUp(InputEventData eventData)
|
|
{
|
|
//Debug.Log(gameObject.name+"OnInputUp");
|
|
}
|
|
/// <summary>
|
|
/// 开始触碰
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnTouchStarted(HandTrackingInputEventData eventData)
|
|
{
|
|
//Debug.Log("接触点位置:"+ eventData.InputData.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 持续触碰
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnTouchUpdated(HandTrackingInputEventData eventData)
|
|
{
|
|
// Debug.Log("接触点位置:" + eventData.InputData.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 结束触碰
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnTouchCompleted(HandTrackingInputEventData eventData)
|
|
{
|
|
//Debug.Log("OnTouchCompleted");
|
|
}
|
|
/// <summary>
|
|
/// 开始抓握
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnManipulationStarted(ManipulationEventData eventData)
|
|
{
|
|
//Debug.Log(eventData.Pointer.Position.ToString());
|
|
}
|
|
/// <summary>
|
|
/// 结束抓握
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnManipulationEnded(ManipulationEventData eventData)
|
|
{
|
|
//Debug.Log("OnManipulationEnded");
|
|
}
|
|
/// <summary>
|
|
/// 开始触碰
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnHoverEntered(ManipulationEventData eventData)
|
|
{
|
|
//Debug.Log("OnHoverEntered");
|
|
}
|
|
/// <summary>
|
|
/// 结束触碰
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnHoverExited(ManipulationEventData eventData)
|
|
{
|
|
//Debug.Log("OnHoverExited");
|
|
}
|
|
/// <summary>
|
|
/// 光标进入
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnFocusEnter(FocusEventData eventData)
|
|
{
|
|
// Debug.Log("OnFocusEnter");
|
|
}
|
|
/// <summary>
|
|
/// 光标移出
|
|
/// </summary>
|
|
/// <param name="eventData"></param>
|
|
public virtual void OnFocusExit(FocusEventData eventData)
|
|
{
|
|
// Debug.Log("OnFocusExit");
|
|
}
|
|
}
|