TV50.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using UnityEngine;
  3. [ExecuteInEditMode]
  4. [RequireComponent(typeof(MeshRenderer))]
  5. public class TV50 : BaseBehaviour
  6. {
  7. private Material material
  8. {
  9. get
  10. {
  11. if (this.SCMaterial == null)
  12. {
  13. this.SCMaterial = new Material(this.SCShader);
  14. this.SCMaterial.hideFlags = HideFlags.HideAndDontSave;
  15. }
  16. return this.SCMaterial;
  17. }
  18. }
  19. private void Start()
  20. {
  21. this.meshRenderer = base.GetComponent<MeshRenderer>();
  22. this.size = this.meshRenderer.bounds.size;
  23. this.SCShader = Shader.Find("CameraFilterPack/FB_TV_50");
  24. if (this.meshRenderer.sharedMaterial == null)
  25. {
  26. this.meshRenderer.sharedMaterial = this.material;
  27. }
  28. }
  29. public void LateUpdate()
  30. {
  31. if (this.SCShader != null)
  32. {
  33. this.TimeX += Time.deltaTime;
  34. if (this.TimeX > 100f)
  35. {
  36. this.TimeX = 0f;
  37. }
  38. this.material.SetFloat("_TimeX", this.TimeX);
  39. this.material.SetVector("_ScreenResolution", new Vector4(this.size.x, this.size.y, 0f, 0f));
  40. }
  41. }
  42. private void Update()
  43. {
  44. }
  45. private void OnDisable()
  46. {
  47. if (this.SCMaterial)
  48. {
  49. UnityEngine.Object.DestroyImmediate(this.SCMaterial);
  50. }
  51. }
  52. public Shader SCShader;
  53. private MeshRenderer meshRenderer;
  54. private Vector3 size;
  55. private float TimeX = 1f;
  56. private Material SCMaterial;
  57. }