【问题标题】:Touch event does not do any action on the Unity c # smartphone触摸事件在 Unity c# 智能手机上不做任何动作
【发布时间】:2017-12-05 16:49:53
【问题描述】:

我有这个代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Audio;
using UnityEngine.EventSystems;

public class start : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    public GameObject musica;
    public bool pulsado;
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
    public void OnPointerDown(PointerEventData eventData)
    {
        pulsado = true;
        audio();
        SceneManager.LoadScene("pajaro");
    }
    public void OnPointerUp(PointerEventData eventData)
    {
        pulsado = false;
    }
    void audio()
    {
        musica.SetActive(true);
    }
}

当我将它导出到Android时,触摸不起作用,但如果它统一工作

【问题讨论】:

  • 我认为您可能需要在收到大量反对票之前对其进行编辑。

标签: c# android unity3d 3d


【解决方案1】:

您正在使用OnPointerDown,这是特定于鼠标的,此事件不会针对触摸输入触发(触摸输入没有“向上”和“向下”的概念) .

为了有触摸输入,你必须在Update()循环中使用Input.touches

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-27
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    相关资源
    最近更新 更多