VFXBuiltInExpression.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Linq;
  3. using UnityEngine;
  4. using UnityEngine.VFX;
  5. namespace UnityEditor.VFX
  6. {
  7. #pragma warning disable 0659
  8. sealed class VFXBuiltInExpression : VFXExpression
  9. {
  10. public static readonly VFXExpression FrameIndex = new VFXBuiltInExpression(VFXExpressionOperation.FrameIndex);
  11. public static readonly VFXExpression TotalTime = new VFXBuiltInExpression(VFXExpressionOperation.TotalTime);
  12. public static readonly VFXExpression DeltaTime = new VFXBuiltInExpression(VFXExpressionOperation.DeltaTime);
  13. public static readonly VFXExpression UnscaledDeltaTime = new VFXBuiltInExpression(VFXExpressionOperation.UnscaledDeltaTime);
  14. public static readonly VFXExpression SystemSeed = new VFXBuiltInExpression(VFXExpressionOperation.SystemSeed);
  15. public static readonly VFXExpression LocalToWorld = new VFXBuiltInExpression(VFXExpressionOperation.LocalToWorld);
  16. public static readonly VFXExpression WorldToLocal = new VFXBuiltInExpression(VFXExpressionOperation.WorldToLocal);
  17. public static readonly VFXExpression GameDeltaTime = new VFXBuiltInExpression(VFXExpressionOperation.GameDeltaTime);
  18. public static readonly VFXExpression GameUnscaledDeltaTime = new VFXBuiltInExpression(VFXExpressionOperation.GameUnscaledDeltaTime);
  19. public static readonly VFXExpression GameSmoothDeltaTime = new VFXBuiltInExpression(VFXExpressionOperation.GameSmoothDeltaTime);
  20. public static readonly VFXExpression GameTotalTime = new VFXBuiltInExpression(VFXExpressionOperation.GameTotalTime);
  21. public static readonly VFXExpression GameUnscaledTotalTime = new VFXBuiltInExpression(VFXExpressionOperation.GameUnscaledTotalTime);
  22. public static readonly VFXExpression GameTotalTimeSinceSceneLoad = new VFXBuiltInExpression(VFXExpressionOperation.GameTotalTimeSinceSceneLoad);
  23. public static readonly VFXExpression GameTimeScale = new VFXBuiltInExpression(VFXExpressionOperation.GameTimeScale);
  24. public static readonly VFXExpression PlayRate = new VFXBuiltInExpression(VFXExpressionOperation.PlayRate);
  25. public static readonly VFXExpression ManagerMaxDeltaTime = new VFXBuiltInExpression(VFXExpressionOperation.ManagerMaxDeltaTime);
  26. public static readonly VFXExpression ManagerFixedTimeStep = new VFXBuiltInExpression(VFXExpressionOperation.ManagerFixedTimeStep);
  27. private static readonly VFXExpression[] AllExpressions = VFXReflectionHelper.CollectStaticReadOnlyExpression<VFXExpression>(typeof(VFXBuiltInExpression));
  28. public static readonly VFXExpressionOperation[] All = AllExpressions.Select(e => e.operation).ToArray();
  29. public static VFXExpression Find(VFXExpressionOperation op)
  30. {
  31. var expression = AllExpressions.FirstOrDefault(e => e.operation == op);
  32. return expression;
  33. }
  34. private VFXExpressionOperation m_Operation;
  35. private VFXBuiltInExpression(VFXExpressionOperation op)
  36. : base(Flags.None)
  37. {
  38. m_Operation = op;
  39. }
  40. public sealed override VFXExpressionOperation operation
  41. {
  42. get
  43. {
  44. return m_Operation;
  45. }
  46. }
  47. public override bool Equals(object obj)
  48. {
  49. if (!(obj is VFXBuiltInExpression))
  50. return false;
  51. var other = (VFXBuiltInExpression)obj;
  52. return valueType == other.valueType && operation == other.operation;
  53. }
  54. protected override int GetInnerHashCode()
  55. {
  56. return operation.GetHashCode();
  57. }
  58. protected sealed override VFXExpression Evaluate(VFXExpression[] constParents)
  59. {
  60. return this;
  61. }
  62. }
  63. #pragma warning restore 0659
  64. }