OnPress长按事件

来源:互联网 发布:无法触碰 知乎 编辑:程序博客网 时间:2024/04/30 00:27
using UnityEngine;
using System.Collections;


public class but1 : MonoBehaviour {
    public float horizontalSpeed = 80f;
    public bool isPress = false;
    // Use this for initialization
    void Start()
    {


    }


    // Update is called once per frame
    void Update()
    {
        if (isPress)
        {
            Camera.main.transform.Translate(Vector3.up * horizontalSpeed * Time.deltaTime);
        }


    }
    void OnPress(bool isPressed)  //OnPress长按事件
    {
        if (isPressed)
        {
            isPress = true;
        }
        else
        {
            isPress = false;
        }
    }
}
0 0
原创粉丝点击