1 using System.Collections;
2 using System.Collections.Generic;
16 public Material fadeMaterial;
21 public Color overlayColor;
26 public float start_value = 0.0f;
31 public float end_value = 1.0f;
36 public float fade_in_duration = 0.5f;
41 public float fade_out_duration = 0.5f;
44 private float stime = 0.0f;
45 private bool do_fade_in =
false;
46 private bool do_fade_out =
false;
48 protected virtual void Awake()
50 if (fadeMaterial == null) fadeMaterial =
new Material(Shader.Find(
"AVR/CameraFade"));
51 overlayColor.a = start_value;
52 fadeMaterial.SetColor(
"_Color", overlayColor);
56 Camera.onPostRender += OnPostRenderCallback;
60 Camera.onPostRender -= OnPostRenderCallback;
77 do_fade_in = do_fade_out =
true;
85 float t = Time.time - stime;
86 overlayColor.a = Mathf.Lerp(start_value, end_value, t / fade_in_duration);
87 fadeMaterial.SetColor(
"_Color", overlayColor);
89 if (t > fade_in_duration)
96 if (do_fade_out && !do_fade_in)
98 float t = Time.time - stime;
99 overlayColor.a = Mathf.Lerp(end_value, start_value, t / fade_out_duration);
100 fadeMaterial.SetColor(
"_Color", overlayColor);
102 if (t > fade_out_duration)
111 return do_fade_in || do_fade_out;
116 if (overlayColor.a > 0 && cam==Camera.main)
120 fadeMaterial.SetPass(0);
122 GL.Color(overlayColor);
override bool isBusy()
True if the effect is starting/started or ending but not yet ended.
override void StartEndEffect()
Start the effect and automatically end it right after
override void EndEffect()
End the effect
Sets the documentation html file inside of Packages/com.avr.core/Documentation/html of a given class...
virtual void OnPostRenderCallback(Camera cam)
Will fade-in / fade-out the screen to a given color on command. NOTE: The color will only be faded fo...
override void StartEffect()
Start the effect