ScreenLoading.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using UnityEngine;
  3. public class ScreenLoading : PostEffectsBase
  4. {
  5. public override bool CheckResources()
  6. {
  7. this.CheckSupport(false);
  8. this.overlayMaterial = this.CheckShaderAndCreateMaterial(this.overlayShader, this.overlayMaterial);
  9. if (!this.isSupported)
  10. {
  11. this.ReportAutoDisable();
  12. }
  13. return this.isSupported;
  14. }
  15. private void OnRenderImage(RenderTexture source, RenderTexture destination)
  16. {
  17. if (!this.CheckResources())
  18. {
  19. Graphics.Blit(source, destination);
  20. return;
  21. }
  22. Vector4 value = new Vector4(1f, 0f, 0f, 1f);
  23. this.overlayMaterial.SetVector("_UV_Transform", value);
  24. this.overlayMaterial.SetFloat("_Intensity", this.intensity);
  25. this.overlayMaterial.SetTexture("_Overlay", this.texture);
  26. Graphics.Blit(source, destination, this.overlayMaterial, (int)this.blendMode);
  27. }
  28. public ScreenLoading.OverlayBlendMode blendMode = ScreenLoading.OverlayBlendMode.Overlay;
  29. public float intensity = 1f;
  30. public Texture2D texture;
  31. public Shader overlayShader;
  32. private Material overlayMaterial;
  33. public enum OverlayBlendMode
  34. {
  35. Additive,
  36. ScreenBlend,
  37. Multiply,
  38. Overlay,
  39. AlphaBlend
  40. }
  41. }