RenderTargetHandle.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using UnityEngine.Scripting.APIUpdating;
  2. namespace UnityEngine.Rendering.Universal
  3. {
  4. [MovedFrom("UnityEngine.Rendering.LWRP")] public struct RenderTargetHandle
  5. {
  6. public int id { set; get; }
  7. public static readonly RenderTargetHandle CameraTarget = new RenderTargetHandle {id = -1};
  8. public void Init(string shaderProperty)
  9. {
  10. id = Shader.PropertyToID(shaderProperty);
  11. }
  12. public RenderTargetIdentifier Identifier()
  13. {
  14. if (id == -1)
  15. {
  16. return BuiltinRenderTextureType.CameraTarget;
  17. }
  18. return new RenderTargetIdentifier(id);
  19. }
  20. public bool Equals(RenderTargetHandle other)
  21. {
  22. return id == other.id;
  23. }
  24. public override bool Equals(object obj)
  25. {
  26. if (ReferenceEquals(null, obj)) return false;
  27. return obj is RenderTargetHandle && Equals((RenderTargetHandle)obj);
  28. }
  29. public override int GetHashCode()
  30. {
  31. return id;
  32. }
  33. public static bool operator==(RenderTargetHandle c1, RenderTargetHandle c2)
  34. {
  35. return c1.Equals(c2);
  36. }
  37. public static bool operator!=(RenderTargetHandle c1, RenderTargetHandle c2)
  38. {
  39. return !c1.Equals(c2);
  40. }
  41. }
  42. }