12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
-
- using UnityEngine;
- public class LoadingFade : MonoBehaviour
- {
-
-
-
- private Material fader;
-
-
-
- private float alpha;
-
-
-
- private bool start = false;
-
-
-
- void Start ()
- {
- alpha = 1.5f;
- fader = new Material(Resources.Load("Materials/GUI/Mat_ZED_Fade") as Material);
- }
- private void OnEnable()
- {
- start = true;
- }
- private void OnDisable()
- {
- start = false;
- }
-
-
-
-
-
-
- private void OnRenderImage(RenderTexture source, RenderTexture destination)
- {
- if (start)
- {
-
-
- alpha -= EaseIn(0.4f, 0, 0.5f, 1.5f);
- }
- alpha = alpha < 0 ? 0 : alpha;
- fader.SetFloat("_Alpha", alpha);
-
- Graphics.Blit(source, destination, fader);
- if (alpha == 0) Destroy(this);
- }
-
-
-
-
-
-
-
-
- static float EaseIn(float t, float b, float c, float d)
- {
- return -c * (Mathf.Sqrt(1 - (t /= d) * t) - 1) + b;
- }
- }
|