using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class MyRotate : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerExitHandler, IPointerEnterHandler
{
public float Ping;
private bool IsStart = false;
private float LastTime = 0;
public int speed;
void Update()
{
if (IsStart && Time.time - LastTime > Ping)
{
IsStart = true;
GameObject mygameobject1 = GameObject.Find("Prefab");//****在双引号里填入需要旋转的物体的名称****
mygameobject1.transform.Rotate(Vector3.left, speed * Time.time);//*Vector3.left表示旋转方向,可以根据要求任意设置。*
}
}
public void LongPress(bool bStart)
{
IsStart = bStart;
LastTime = Time.time;
}
U3D Button应用 长按按钮实现物体的旋转,松开时停止旋转
最新推荐文章于 2023-04-03 16:42:16 发布