You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
834 B
35 lines
834 B
using UnityEngine; |
|
|
|
namespace Utils |
|
{ |
|
public class AutoScale : MonoBehaviour |
|
{ |
|
|
|
[SerializeField] private Vector3 _from; |
|
[SerializeField] private Vector3 _to; |
|
[SerializeField] private float _time; |
|
[SerializeField] private bool _autoDestroy; |
|
|
|
private float _currentTime; |
|
|
|
private void Start() |
|
{ |
|
transform.localScale = _from; |
|
} |
|
|
|
private void Update() |
|
{ |
|
_currentTime += Time.deltaTime; |
|
if (_currentTime >= _time) |
|
{ |
|
if (_autoDestroy) |
|
Destroy(gameObject); |
|
else |
|
Destroy(this); |
|
} |
|
|
|
var step = _currentTime / _time; |
|
transform.localScale = Vector3.Lerp(_from, _to, step); |
|
} |
|
} |
|
}
|
|
|