Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class LerpLight : MonoBehaviour
- {
- public float progress;
- public float speed = 0.5f;
- bool _checker = true;
- Light _myLight;
- Quaternion _originalRotation;
- Vector3 _originalPosition;
- public Color lerpColorFrom;
- public Color lerpColorTo;
- void Start()
- {
- _originalPosition = transform.position;
- _originalRotation = transform.rotation;
- _myLight = GetComponent<Light>();
- }
- void Update()
- {
- if (_checker)
- {
- progress = progress + speed * Time.deltaTime;
- progress = Mathf.Clamp01(progress);
- _myLight.color = Color.Lerp(lerpColorFrom, lerpColorTo, progress);
- //transform.rotation = Quaternion.Slerp(_originalRotation, Quaternion.identity, progress);
- //transform.position = Vector3.Lerp(_originalPosition, Vector3.zero, progress);
- }
- else
- {
- progress = progress + speed * Time.deltaTime;
- progress = Mathf.Clamp01(progress);
- _myLight.color = Color.Lerp(lerpColorTo, lerpColorFrom, progress);
- //transform.rotation = Quaternion.Slerp(Quaternion.identity, _originalRotation, progress);
- //transform.position = Vector3.Lerp(Vector3.zero, _originalPosition, progress);
- }
- if (progress == 1)
- {
- _checker = !_checker;
- progress = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement