using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.Animations;
using UnityEngine.Events;
using UnityEngine.EventSystems;
public class AnimationSpeed : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerExitHandler
{
public float speed = 1;//动画播放速度
private float delay = 0.2f;//延迟时间
private bool isDown = false;// 按钮是否是按下状态
private float lastIsDownTime;// 按钮最后一次是被按住状态时候的时间
public Animator anim;//动画
void Start()
{
anim.speed = 1;
}
// Update is called once per frame
void Update()
{
// 如果按钮是被按下状态
if (isDown)
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.Animations;
using UnityEngine.Events;
using UnityEngine.EventSystems;
public class AnimationSpeed : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerExitHandler
{
public float speed = 1;//动画播放速度
private float delay = 0.2f;//延迟时间
private bool isDown = false;// 按钮是否是按下状态
private float lastIsDownTime;// 按钮最后一次是被按住状态时候的时间
public Animator anim;//动画
void Start()
{
anim.speed = 1;
}
// Update is called once per frame
void Update()
{
// 如果按钮是被按下状态
if (isDown)

这篇博客介绍了一个Unity脚本,实现了通过长按游戏界面按钮来控制Animator动画的播放速度。使用IPointerDownHandler、IPointerUpHandler和IPointerExitHandler接口,当按钮被长按时,动画速度会逐渐增加,达到一定限制后不再增加。松开按钮或鼠标离开按钮时,速度恢复到初始值。
最低0.47元/天 解锁文章
2万+

被折叠的 条评论
为什么被折叠?



