using System; using System.Collections; using System.Collections.Generic; using Sirenix.OdinInspector; using UnityEngine; public class ScaleTarget : MonoBehaviour { [SerializeField] private Transform target; [SerializeField] private float minScale = 1f; [SerializeField] private float maxScale = 2f; [SerializeField] private Vector3 scaleAxis = Vector3.right; [SerializeField] private float speed = 1f; [Range(0f, 1f)] [SerializeField] private float inputValue = 0f; [Range(-1f, 1f)] [SerializeField, ReadOnly] private float direction = 0f; [SerializeField] private bool invertDirection = false; private void Update() { if (target == null) return; RemapDirection(); target.localScale += scaleAxis * (speed * direction * Time.deltaTime); // Clamp the scale but only on the scale axis var clampedScale = target.localScale; clampedScale.x = Mathf.Clamp(clampedScale.x, minScale, maxScale); clampedScale.y = Mathf.Clamp(clampedScale.y, minScale, maxScale); clampedScale.z = Mathf.Clamp(clampedScale.z, minScale, maxScale); target.localScale = clampedScale; } private void RemapDirection(float min = -1f, float max = 1f) { direction = Mathf.Lerp(min, max, inputValue); direction *= invertDirection ? -1f : 1f; } public void SetDirectionValue(float value) => inputValue = value; }