////////////////////////////////////////////////////// // MicroSplat // Copyright (c) Jason Booth ////////////////////////////////////////////////////// using System.Collections; using System.Collections.Generic; using UnityEngine; namespace JBooth.MicroSplat { [ExecuteInEditMode] [RequireComponent(typeof(Light))] public class GlitterLight : MonoBehaviour { Light lght = null; #if UNITY_EDITOR void OnEnable() { UnityEditor.EditorApplication.update += Update; lght = GetComponent (); } void OnDisable() { UnityEditor.EditorApplication.update -= Update; lght = GetComponent (); } #else void OnEnable() { lght = GetComponent (); } void OnDisable() { lght = GetComponent (); } #endif void Update () { Shader.SetGlobalVector("_gGlitterLightDir", -this.transform.forward); Shader.SetGlobalVector("_gGlitterLightWorldPos", this.transform.position); if (lght != null) { Shader.SetGlobalColor ("_gGlitterLightColor", lght.color); } } } }