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); } }

相关推荐
zyh______5 小时前
关于unity的序列化
unity·游戏引擎
weixin_409383125 小时前
godot碰撞测试的学习
学习·游戏引擎·godot
电子云与长程纠缠5 小时前
Godot学习06 - AnimationPlayer内置动画
学习·游戏引擎·godot
星夜泊客7 小时前
C# : 引用类型都存在堆上吗
unity·c#
点量云实时渲染-小芹7 小时前
Unity模型数字孪生虚拟仿真webgl推流卡实时云渲染推流
unity·webgl·数字孪生·实时云渲染·虚拟仿真·云推流
mxwin13 小时前
Unity Shader 齐次坐标与透视除法理解 SV_POSITION 的 w 分量
unity·游戏引擎·shader
NPUQS16 小时前
【Unity 3D学习】Unity 与 Python 互通入门:点击按钮调用 Python(超简单示例)
学习·3d·unity
电子云与长程纠缠1 天前
Godot学习05 - 播放与分离FBX动画
学习·游戏引擎·godot
小贺儿开发1 天前
【Arduino与Unity交互探究】03 超声波测距模块
unity·arduino·串口通信·传感器·videoplayer·硬件交互
weixin_409383121 天前
godot等轴视角tilemaplayer的学习 isocheric的素材xy大小怎么调
学习·游戏引擎·godot