Singularity/Assets/Scripts/ScaleController.cs

20 lines
574 B
C#
Raw Normal View History

2024-05-06 14:45:45 -04:00
using UnityEngine;
using UnityEngine.UI;
public class ScaleController : MonoBehaviour
{
public Transform targetTransform; // The transform whose scale you want to control
public Slider scaleSlider; // The slider that controls the scale
private Vector3 initialScale; // The initial scale of the target transform
void Start()
{
initialScale = targetTransform.localScale;
}
public void OnSliderValueChanged() {
float scaleFactor = scaleSlider.value / 100f; // Assuming the slider goes from 0 to 100
targetTransform.localScale = initialScale * scaleFactor;
}
}