Skip to content

Commit

Permalink
feat: add 'TimeScaleMultiplier' option
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Feb 21, 2025
1 parent d1a1e23 commit 925af0b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Packages/src/Editor/UIParticleEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ internal class State : ScriptableSingleton<State>
private SerializedProperty _autoScalingMode;
private SerializedProperty _useCustomView;
private SerializedProperty _customViewSize;
private SerializedProperty _timeScaleMultiplier;
private ReorderableList _ro;
private bool _showMax;
private bool _is3DScaleMode;
Expand Down Expand Up @@ -100,6 +101,7 @@ protected override void OnEnable()
_autoScalingMode = serializedObject.FindProperty("m_AutoScalingMode");
_useCustomView = serializedObject.FindProperty("m_UseCustomView");
_customViewSize = serializedObject.FindProperty("m_CustomViewSize");
_timeScaleMultiplier = serializedObject.FindProperty("m_TimeScaleMultiplier");

var sp = serializedObject.FindProperty("m_Particles");
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true)
Expand Down Expand Up @@ -244,6 +246,9 @@ public override void OnInspectorGUI()
_customViewSize.floatValue = Mathf.Max(0.1f, _customViewSize.floatValue);
}

// Time Scale Multiplier
EditorGUILayout.PropertyField(_timeScaleMultiplier);

// Target ParticleSystems.
EditorGUI.BeginChangeCheck();
_ro.DoLayoutList();
Expand Down
13 changes: 13 additions & 0 deletions Packages/src/Runtime/UIParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public enum PositionMode
"Change the bake view size.")]
private float m_CustomViewSize = 10;

[SerializeField]
[Tooltip("Time scale multiplier.")]
private float m_TimeScaleMultiplier = 1;

private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>();
private Camera _bakeCamera;
private int _groupId;
Expand Down Expand Up @@ -257,6 +261,15 @@ public float customViewSize
set => m_CustomViewSize = Mathf.Max(0.1f, value);
}

/// <summary>
/// Time scale multiplier.
/// </summary>
public float timeScaleMultiplier
{
get => m_TimeScaleMultiplier;
set => m_TimeScaleMultiplier = value;
}

internal bool useMeshSharing => m_MeshSharing != MeshSharing.None;

internal bool isPrimary =>
Expand Down
1 change: 1 addition & 0 deletions Packages/src/Runtime/UIParticleRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ private void Simulate(Vector3 scale, bool paused)
: main.useUnscaledTime
? Time.unscaledDeltaTime
: Time.deltaTime;
deltaTime *= _parent.timeScaleMultiplier;

// Pre-warm:
if (0 < deltaTime && _preWarm)
Expand Down

0 comments on commit 925af0b

Please sign in to comment.