You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
2 months ago
|
//using UnityEngine;
|
||
|
//using UnityEngine.UI;
|
||
|
|
||
|
//public class SteeringSliderController : MonoBehaviour
|
||
|
//{
|
||
|
// public Slider steeringSlider;
|
||
|
// public VehicleController vehicleController;
|
||
|
|
||
|
// void Start()
|
||
|
// {
|
||
|
// if (steeringSlider != null && vehicleController != null)
|
||
|
// {
|
||
|
// steeringSlider.onValueChanged.AddListener(SetSteeringFactor);
|
||
|
// SetSteeringFactor(steeringSlider.value); // Set initial value
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// public Text steeringValueText;
|
||
|
|
||
|
// void SetSteeringFactor(float value)
|
||
|
// {
|
||
|
// vehicleController.steeringFactor = value;
|
||
|
// if (steeringValueText != null)
|
||
|
// steeringValueText.text = "Steering Factor: "+value.ToString("F2");
|
||
|
// }
|
||
|
|
||
|
//}
|
||
|
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class SteeringSliderController : MonoBehaviour
|
||
|
{
|
||
|
public Slider _steeringSlider;
|
||
|
public VehicleController _linkedController;
|
||
|
public Text _steeringFactorText;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
if (_steeringSlider != null && _linkedController != null)
|
||
|
{
|
||
|
_steeringSlider.onValueChanged.AddListener(UpdateSteeringFactor);
|
||
|
UpdateSteeringFactor(_steeringSlider.value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void UpdateSteeringFactor(float newValue)
|
||
|
{
|
||
|
_linkedController.steeringFactor = newValue;
|
||
|
if (_steeringFactorText != null)
|
||
|
_steeringFactorText.text = $"Steering Factor: {newValue:F2}";
|
||
|
}
|
||
|
}
|
||
|
|