You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PhishingAwarenessSimulation/Assets/ZoomTween.cs

29 lines
746 B
C#

using DG.Tweening;
using UnityEngine;
public class ZoomTween : MonoBehaviour
{
[Header("Material and Property")]
public Material targetMaterial;
[Tooltip("Zoom range e.g., from 0.1 (zoomed in) to 5 (zoomed out)")]
public float minZoom = 0.1f;
public float maxZoom = 2f;
public float speed = 1f;
[Tooltip("Name of the shader property (must match _ZoomUvAmount)")]
private readonly string zoomProperty = "_ZoomUvAmount";
private float t;
void Update()
{
if (!targetMaterial) return;
t += Time.deltaTime * speed;
// Animate using ping-pong
float zoom = Mathf.Lerp(minZoom, maxZoom, Mathf.PingPong(t, 1f));
targetMaterial.SetFloat(zoomProperty, zoom);
}
}