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

相关推荐
死也不注释2 小时前
【Unity UGUI 交互组件——Slider(7)】
unity·游戏引擎·交互
程序猿多布7 小时前
XLua教程之热补丁技术
unity·c#·lua·xlua
SmalBox10 小时前
【光照】Unity中的[光照模型]概念辨析
unity·渲染
挂科是不可能出现的10 小时前
unity导入blender动画
unity·游戏引擎·blender
派葛穆11 小时前
Unity-按钮实现场景跳转
java·unity·游戏引擎
程序猿多布13 小时前
XLua教程之Lua调用C#
unity·c#·lua·xlua
lrh30251 天前
Custom SRP - Point and Spot Lights
unity·srp·render pipeline
绀目澄清1 天前
unity UGUI 鼠标画线
unity·计算机外设·游戏引擎
Magnum Lehar1 天前
3d wpf游戏引擎的导入文件功能c++的.h实现
3d·游戏引擎·wpf
作孽就得先起床1 天前
unity pcd 二进制版 简单显示文件对象(单色)
unity·游戏引擎