DisplayBackground.cs 914 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using UnityEngine;
  3. namespace RenderHeads.Media.AVProVideo
  4. {
  5. [AddComponentMenu("AVPro Video/Display Background", 200)]
  6. [HelpURL("http://renderheads.com/product/avpro-video/")]
  7. [ExecuteInEditMode]
  8. public class DisplayBackground : MonoBehaviour
  9. {
  10. private void OnRenderObject()
  11. {
  12. if (this._material == null || this._texture == null)
  13. {
  14. return;
  15. }
  16. Vector4 vector = new Vector4(0f, 0f, 1f, 1f);
  17. this._material.SetPass(0);
  18. GL.PushMatrix();
  19. GL.LoadOrtho();
  20. GL.Begin(7);
  21. GL.TexCoord2(vector.x, vector.y);
  22. GL.Vertex3(0f, 0f, 0.1f);
  23. GL.TexCoord2(vector.z, vector.y);
  24. GL.Vertex3(1f, 0f, 0.1f);
  25. GL.TexCoord2(vector.z, vector.w);
  26. GL.Vertex3(1f, 1f, 0.1f);
  27. GL.TexCoord2(vector.x, vector.w);
  28. GL.Vertex3(0f, 1f, 0.1f);
  29. GL.End();
  30. GL.PopMatrix();
  31. }
  32. public IMediaProducer _source;
  33. public Texture2D _texture;
  34. public Material _material;
  35. }
  36. }