Stratasys-450mc-VR/Assets/Scripts/ScaleTarget.cs

28 lines
870 B
C#
Raw Normal View History

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;
public void Scale(float value)
{
target.localScale += scaleAxis * (value * speed * Time.deltaTime);
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;
}
}