ParticleScalerExtensions.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. 
  2. // =================================
  3. // Namespaces.
  4. // =================================
  5. using UnityEngine;
  6. using UnityEditor;
  7. // =================================
  8. // Define namespace.
  9. // =================================
  10. namespace MirzaBeig
  11. {
  12. namespace EditorExtensions
  13. {
  14. namespace Utilities
  15. {
  16. // =================================
  17. // Classes.
  18. // =================================
  19. public static class ParticleScalerExtensions
  20. {
  21. // =================================
  22. // Nested classes and structures.
  23. // =================================
  24. // ...
  25. // =================================
  26. // Variables.
  27. // =================================
  28. // ...
  29. // =================================
  30. // Functions.
  31. // =================================
  32. // Scales against self.
  33. public static void scale(this ParticleSystem particleSystem, float scale, bool scaleTransformLocalPosition)
  34. {
  35. // Transform.
  36. if (scaleTransformLocalPosition)
  37. {
  38. particleSystem.transform.localPosition *= scale;
  39. }
  40. // Particle system.
  41. ParticleSystem.MainModule main = particleSystem.main;
  42. ParticleSystem.ShapeModule shape = particleSystem.shape;
  43. ParticleSystem.VelocityOverLifetimeModule velocityOverLifetime = particleSystem.velocityOverLifetime;
  44. ParticleSystem.LimitVelocityOverLifetimeModule limitVelocityOverLifetime = particleSystem.limitVelocityOverLifetime;
  45. ParticleSystem.ForceOverLifetimeModule forceOverLifetime = particleSystem.forceOverLifetime;
  46. ParticleSystem.MinMaxCurve mmCurve;
  47. // Main.
  48. mmCurve = main.startSpeed;
  49. mmCurve.constantMin *= scale;
  50. mmCurve.constantMax *= scale;
  51. main.startSpeed = mmCurve;
  52. mmCurve = main.startSize;
  53. mmCurve.constantMin *= scale;
  54. mmCurve.constantMax *= scale;
  55. main.startSize = mmCurve;
  56. // Shape.
  57. shape.radius *= scale;
  58. shape.scale *= scale;
  59. shape.angle *= scale;
  60. shape.randomDirectionAmount *= scale;
  61. shape.sphericalDirectionAmount *= scale;
  62. shape.normalOffset *= scale;
  63. // Velocity over lifetime.
  64. mmCurve = velocityOverLifetime.x;
  65. mmCurve.constantMin *= scale;
  66. mmCurve.constantMax *= scale;
  67. velocityOverLifetime.x = mmCurve;
  68. mmCurve = velocityOverLifetime.y;
  69. mmCurve.constantMin *= scale;
  70. mmCurve.constantMax *= scale;
  71. velocityOverLifetime.y = mmCurve;
  72. mmCurve = velocityOverLifetime.z;
  73. mmCurve.constantMin *= scale;
  74. mmCurve.constantMax *= scale;
  75. velocityOverLifetime.z = mmCurve;
  76. // Force over lifetime.
  77. mmCurve = forceOverLifetime.x;
  78. mmCurve.constantMin *= scale;
  79. mmCurve.constantMax *= scale;
  80. forceOverLifetime.x = mmCurve;
  81. mmCurve = forceOverLifetime.y;
  82. mmCurve.constantMin *= scale;
  83. mmCurve.constantMax *= scale;
  84. forceOverLifetime.y = mmCurve;
  85. mmCurve = forceOverLifetime.z;
  86. mmCurve.constantMin *= scale;
  87. mmCurve.constantMax *= scale;
  88. forceOverLifetime.z = mmCurve;
  89. }
  90. // =================================
  91. // End functions.
  92. // =================================
  93. }
  94. // =================================
  95. // End namespace.
  96. // =================================
  97. }
  98. }
  99. }
  100. // =================================
  101. // --END-- //
  102. // =================================