2023-11-03 13:38:36 -04:00
|
|
|
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;
|
|
|
|
|
2023-11-14 13:38:38 -05:00
|
|
|
public void Scale(float value)
|
2023-11-03 13:38:36 -04:00
|
|
|
{
|
2023-11-14 13:38:38 -05:00
|
|
|
target.localScale += scaleAxis * (value * speed * Time.deltaTime);
|
2023-11-03 13:38:36 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|