如何在多维数据集中动态创建OnPointerDownMixedRealityPointerEventData?

问题描述 投票:0回答:1

我正在使用MRTK 2.3.0版本,当“事件指针向下”创建一个新的GameObject多维数据集时,我创建了一个拖动的多维数据集,但是新的多维数据集没有事件。我想为其分配一个事件。如何通过代码分配事件?]​​>

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Microsoft.MixedReality.Toolkit.Input;

    public class TouchableCube : MonoBehaviour, IMixedRealityPointerHandler
    {
        Color colorBlue = Color.blue;
        Renderer rend;

        public void OnPointerClicked(MixedRealityPointerEventData eventData)
        {
            rend.material.color = colorBlue;
        }


        public void OnPointerDown(MixedRealityPointerEventData eventData)
        {
            rend.material.color = Color.red;
            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.transform.position = new Vector3(0,0,2);

            cube.SetActive(true);


        }

        public void OnPointerDragged(MixedRealityPointerEventData eventData)
        {
            rend.material.color = Color.yellow;
            Vector3 v = new Vector3(
                               eventData.Pointer.Position.x,
                               eventData.Pointer.Position.y, 
                               eventData.Pointer.Position.z);
            rend.transform.position = v;   
        }

我正在使用MRTK 2.3.0版本,当“事件指针向下”创建一个新的GameObject多维数据集时,我创建了一个拖动的多维数据集,但是新的多维数据集没有事件。我想为其分配一个事件。怎么...

unity3d hololens mrtk
1个回答
1
投票
© www.soinside.com 2019 - 2024. All rights reserved.