using Framework.Core; using UnityEngine; namespace AibisDream { public class AirDashboard : Dashboard { [FindComponent] private SpriteRenderer _pointer; [FindComponent("Min Pointer")] private Transform _minPointer; [FindComponent("Max Pointer")] private Transform _maxPointer; [SerializeField] private float topPosY; [SerializeField] private float bottomPosY; private float _pointerMaxHeight; protected override void OnStart() { _pointerMaxHeight = _pointer.size.y; } protected override void UpdateDashboard(EngineData data) { // 气门 _pointer.size = new Vector2(_pointer.size.x, data.curAir * _pointerMaxHeight); // 气门上下限 var minPosY = (topPosY - bottomPosY) * data.curAirMin + bottomPosY; var maxPosY = (topPosY - bottomPosY) * data.curAirMax + bottomPosY; _minPointer.localPosition = new Vector3(0, minPosY, 0); _maxPointer.localPosition = new Vector3(0, maxPosY, 0); } } }