Unity 不规则进度条显示根据点对点进行

using UniRx;

using UnityEngine;

using UnityEngine.UI;

public class SpeedVehicle : MonoBehaviour

{

//加速踏板

SerializeField\] private Image AcceleratorApertureSlider; //制动踏板 \[SerializeField\] private Image BrakingPedalApertureSlider; private static readonly string TAG = "SpeedVehicle"; private void Start() { //当前加速踏板进度 DataCenter.AcceleratorAperture.Subscribe(f => { Log.I(TAG, "AcceleratorAperture select value: " + f); float fillAmount = f / 100f; AcceleratorApertureSlider.fillAmount = fillAmount; //SetAnimationFrame(AcceleratorApertureSlider, f * 100); AcceleratorAperture(fillAmount); }).AddTo(this); //当前制动踏板进度 DataCenter.BrakingPedalAperture.Subscribe(f => { Log.I(TAG, "BrakingPedalAperture select value: " + f); float fillAmount = Normalize(f, 10, 45); BrakingPedalApertureSlider.fillAmount = fillAmount; //SetAnimationFrame(BrakingPedalApertureSlider, f * 100); BrakingPedalAperture(fillAmount); }).AddTo(this); } protected virtual void AcceleratorAperture(float fillAmount) { } protected virtual void BrakingPedalAperture(float fillAmount) { } private float Normalize(float value, float min, float max) { return (value - min) / (max - min); } private void SetAnimationFrame(Animation animation, float frameToFreeze) { // 第N帧对应的时间(秒) float timeAtNthFrame = frameToFreeze / 25f; animation.clip.SampleAnimation(animation.gameObject, timeAtNthFrame); } }

相关推荐
Thomas_YXQ1 天前
Unity3D编辑器扩展-物体批量替换设置材质
游戏·unity·编辑器·游戏引擎·材质
雪下的新火1 天前
Unity-HDRP场景搭建-那山
经验分享·笔记·unity·游戏引擎·场景搭建
郝学胜-神的一滴1 天前
深度解析游戏引擎中的相机:视图矩阵
程序人生·unity·矩阵·游戏引擎·godot·图形渲染·虚幻
谷宇.2 天前
【Unity3D实例-功能-拔枪】角色拔枪(三)IK的使用-紧握武器
游戏·unity·c#·unity3d·游戏开发·游戏编程·steam
SmalBox2 天前
【渲染流水线】[逐片元阶段]-[模版测试]以UnityURP为例
unity·渲染
小蜗 strong3 天前
unity中实现机械臂自主运动
unity·游戏引擎
★YUI★3 天前
学习游戏制作记录(制作系统与物品掉落系统)8.16
学习·游戏·ui·unity·c#
SmalBox3 天前
【渲染流水线】[逐片元阶段]-[透明度测试]以UnityURP为例
unity·渲染
三只坚果4 天前
blender制作动画导入unity两种方式
unity·游戏引擎·blender
benben0444 天前
《Unity Shader入门精要》学习笔记二
unity·unity shader