Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- // Script that goes with WavySphere shader: https://pastebin.com/AZiuUYwp
- // Made by Erika Moya
- public class ChangeColor : MonoBehaviour {
- public Gradient colorGradient;
- public float strobeDuration = 2f;
- SkinnedMeshRenderer rend;
- public float startPoint = 5f;
- public int seconds = 5;
- public float speed = 1.00f;
- public float blend = 0;
- public Light light;
- public float t;
- float startTime;
- public bool loop = true;
- private void Start()
- {
- rend = GetComponent<SkinnedMeshRenderer>();
- startTime = Time.time;
- t = startPoint;
- rend.material.SetFloat("_Blend", 0);
- rend.SetBlendShapeWeight(1, 0);
- RenderSettings.ambientLight = Color.grey;
- }
- // Update is called once per frame
- void Update ()
- {
- float p = Mathf.PingPong(Time.time / strobeDuration, 1f);
- rend.material.SetColor("_Color", colorGradient.Evaluate(p));
- t -= Time.deltaTime;
- if (t < 0 || !loop)
- {
- p = (Time.time - startPoint) * speed;
- //blend = Mathf.Lerp(0, 1, t / seconds);
- blend = Mathf.PingPong(p / seconds, 1f);
- if (blend >= 0.97)
- {
- t = startPoint;
- blend = 1;
- }
- if (blend <= 0.03)
- {
- t = startPoint;
- blend = 0;
- }
- rend.material.SetFloat("_Blend", blend);
- rend.SetBlendShapeWeight(1, blend * 100);
- RenderSettings.ambientLight = Color.Lerp(Color.grey, Color.white, blend);
- light.intensity = Mathf.Lerp(.35f, 0, blend);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement