unity3d:htc wavesdk,VR一体机滑块与按钮事件

2023-08-24 14:58:37 浏览数 (1)

点击VR一体机上触摸板,可使滑块定位,与按钮响应

InputModuleManager

改为PointerDown,因为滑块之类的无点击事件

增加按钮响应,把监听click改为监听down

代码语言:javascript复制
using UnityEngine;
using System.Collections;
using UnityEngine.Events;
using UnityEngine.EventSystems;

public class ClickListener : MonoBehaviour, IPointerClickHandler, IPointerDownHandler
{
    public delegate void VoidDelegate(GameObject go);
    public VoidDelegate onClick;
    public VoidDelegate onDown;
    public VoidDelegate onNewGuideClick;

    static public ClickListener Get(GameObject go)
    {
        ClickListener listener = go.GetComponent<ClickListener>();
        if (listener == null) listener = go.AddComponent<ClickListener>();
        return listener;
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        if (onClick != null)
        {
            onClick(gameObject);
        }

        if (onNewGuideClick != null && DataMgr.m_isNewGuide == true)
        {
            onNewGuideClick(gameObject);
        }
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        if (onDown != null)
        {
            onDown(gameObject);
        }
    }
}

按钮监听响应

代码语言:javascript复制
 ClickListener.Get(m_btnMovie.gameObject).onDown = (param) => { PublicFunc.GotoNextScene("DianYingYuan"); };

0 人点赞