VFXExpressionTextureValues.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System;
  2. using System.Linq;
  3. using System.Runtime.CompilerServices;
  4. using UnityEngine;
  5. using UnityEngine.VFX;
  6. using Object = UnityEngine.Object;
  7. namespace UnityEditor.VFX
  8. {
  9. class VFXTexture2DValue : VFXObjectValue
  10. {
  11. public VFXTexture2DValue(int instanceID = 0, Mode mode = Mode.FoldableVariable) : base(instanceID, mode, VFXValueType.Texture2D)
  12. {
  13. }
  14. sealed public override VFXValue CopyExpression(Mode mode)
  15. {
  16. var copy = new VFXTexture2DValue(Get(), mode);
  17. return copy;
  18. }
  19. }
  20. class VFXTexture3DValue : VFXObjectValue
  21. {
  22. public VFXTexture3DValue(int instanceID = 0, Mode mode = Mode.FoldableVariable) : base(instanceID, mode, VFXValueType.Texture3D)
  23. {
  24. }
  25. sealed public override VFXValue CopyExpression(Mode mode)
  26. {
  27. var copy = new VFXTexture3DValue(Get(), mode);
  28. return copy;
  29. }
  30. }
  31. class VFXTextureCubeValue : VFXObjectValue
  32. {
  33. public VFXTextureCubeValue(int instanceID = 0, Mode mode = Mode.FoldableVariable) : base(instanceID, mode, VFXValueType.TextureCube)
  34. {
  35. }
  36. sealed public override VFXValue CopyExpression(Mode mode)
  37. {
  38. var copy = new VFXTextureCubeValue(Get(), mode);
  39. return copy;
  40. }
  41. }
  42. class VFXTexture2DArrayValue : VFXObjectValue
  43. {
  44. public VFXTexture2DArrayValue(int instanceID = 0, Mode mode = Mode.FoldableVariable) : base(instanceID, mode, VFXValueType.Texture2DArray)
  45. {
  46. }
  47. sealed public override VFXValue CopyExpression(Mode mode)
  48. {
  49. var copy = new VFXTexture2DArrayValue(Get(), mode);
  50. return copy;
  51. }
  52. }
  53. class VFXTextureCubeArrayValue : VFXObjectValue
  54. {
  55. public VFXTextureCubeArrayValue(int instanceID = 0, Mode mode = Mode.FoldableVariable) : base(instanceID, mode, VFXValueType.TextureCubeArray)
  56. {
  57. }
  58. sealed public override VFXValue CopyExpression(Mode mode)
  59. {
  60. var copy = new VFXTextureCubeArrayValue(Get(), mode);
  61. return copy;
  62. }
  63. }
  64. class VFXCameraBufferValue : VFXValue<int>
  65. {
  66. public VFXCameraBufferValue(int instanceID = 0, Mode mode = Mode.FoldableVariable) : base(instanceID, mode)
  67. {
  68. }
  69. public override VFXValue CopyExpression(Mode mode)
  70. {
  71. var copy = new VFXCameraBufferValue(Get(), mode);
  72. return copy;
  73. }
  74. public override VFXValueType valueType { get { return VFXValueType.CameraBuffer; } }
  75. sealed protected override int[] additionnalOperands { get { return new int[] { (int)valueType }; } }
  76. public override T Get<T>()
  77. {
  78. CameraBuffer cameraBuffer = base.Get();
  79. object value = cameraBuffer;
  80. if (typeof(T) == typeof(int))
  81. value = (int)cameraBuffer;
  82. if (typeof(T).IsAssignableFrom(typeof(Texture)))
  83. value = (Texture)cameraBuffer;
  84. return (T)value;
  85. }
  86. public override object GetContent()
  87. {
  88. return Get();
  89. }
  90. public override void SetContent(object value)
  91. {
  92. m_Content = (int)(CameraBuffer)value;
  93. }
  94. }
  95. class VFXMeshValue : VFXObjectValue
  96. {
  97. public VFXMeshValue(int instanceID = 0, Mode mode = Mode.FoldableVariable) : base(instanceID, mode, VFXValueType.Mesh)
  98. {
  99. }
  100. sealed public override VFXValue CopyExpression(Mode mode)
  101. {
  102. var copy = new VFXMeshValue(Get(), mode);
  103. return copy;
  104. }
  105. }
  106. class VFXSkinnedMeshRendererValue : VFXObjectValue
  107. {
  108. public VFXSkinnedMeshRendererValue(int instanceID = 0, Mode mode = Mode.FoldableVariable) : base(instanceID, mode, VFXValueType.SkinnedMeshRenderer)
  109. {
  110. }
  111. sealed public override VFXValue CopyExpression(Mode mode)
  112. {
  113. var copy = new VFXSkinnedMeshRendererValue(Get(), mode);
  114. return copy;
  115. }
  116. }
  117. class VFXGraphicsBufferValue : VFXObjectValue
  118. {
  119. public VFXGraphicsBufferValue(int instanceID = 0, Mode mode = Mode.FoldableVariable) : base(instanceID, mode, VFXValueType.Buffer)
  120. {
  121. }
  122. sealed public override VFXValue CopyExpression(Mode mode)
  123. {
  124. var copy = new VFXGraphicsBufferValue(Get(), mode);
  125. return copy;
  126. }
  127. }
  128. }