VFXExpressionSampleAttributeMap.cs 1.1 KB

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Linq;
  3. using System.Runtime.CompilerServices;
  4. using UnityEngine;
  5. using UnityEngine.VFX;
  6. namespace UnityEditor.VFX
  7. {
  8. class VFXExpressionSampleAttributeMap<T> : VFXExpression
  9. {
  10. public VFXExpressionSampleAttributeMap() : this(VFXTexture2DValue.Default, VFXValue<int>.Default, VFXValue<int>.Default)
  11. {
  12. }
  13. public VFXExpressionSampleAttributeMap(VFXExpression texture, VFXExpression x, VFXExpression y)
  14. : base(Flags.InvalidOnCPU, new VFXExpression[3] { texture, x, y })
  15. { }
  16. sealed public override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } }
  17. sealed public override VFXValueType valueType { get { return VFXExpression.GetVFXValueTypeFromType(typeof(T)); } }
  18. public sealed override string GetCodeString(string[] parents)
  19. {
  20. string typeString = VFXExpression.TypeToCode(valueType);
  21. return string.Format("({3}){0}.Load(int3({1}, {2}, 0))", parents[0], parents[1], parents[2], typeString);
  22. }
  23. }
  24. }