feat: 'AbsoluteMode' option is renamed to 'PositionMode'
AbsoluteMode property is obsoletepull/289/head
parent
4851a1880e
commit
67eff61073
|
@ -74,8 +74,8 @@ namespace Coffee.UIExtensions
|
||||||
private SerializedProperty _meshSharing;
|
private SerializedProperty _meshSharing;
|
||||||
private SerializedProperty _groupId;
|
private SerializedProperty _groupId;
|
||||||
private SerializedProperty _groupMaxId;
|
private SerializedProperty _groupMaxId;
|
||||||
private SerializedProperty _absoluteMode;
|
|
||||||
private SerializedProperty _ignoreCanvasScaler;
|
private SerializedProperty _ignoreCanvasScaler;
|
||||||
|
private SerializedProperty _positionMode;
|
||||||
private ReorderableList _ro;
|
private ReorderableList _ro;
|
||||||
private bool _showMax;
|
private bool _showMax;
|
||||||
|
|
||||||
|
@ -157,8 +157,8 @@ namespace Coffee.UIExtensions
|
||||||
_meshSharing = serializedObject.FindProperty("m_MeshSharing");
|
_meshSharing = serializedObject.FindProperty("m_MeshSharing");
|
||||||
_groupId = serializedObject.FindProperty("m_GroupId");
|
_groupId = serializedObject.FindProperty("m_GroupId");
|
||||||
_groupMaxId = serializedObject.FindProperty("m_GroupMaxId");
|
_groupMaxId = serializedObject.FindProperty("m_GroupMaxId");
|
||||||
_absoluteMode = serializedObject.FindProperty("m_AbsoluteMode");
|
|
||||||
_ignoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler");
|
_ignoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler");
|
||||||
|
_positionMode = serializedObject.FindProperty("m_PositionMode");
|
||||||
|
|
||||||
var sp = serializedObject.FindProperty("m_Particles");
|
var sp = serializedObject.FindProperty("m_Particles");
|
||||||
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true)
|
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true)
|
||||||
|
@ -272,8 +272,8 @@ namespace Coffee.UIExtensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Absolute Mode
|
// Position Mode
|
||||||
EditorGUILayout.PropertyField(_absoluteMode);
|
EditorGUILayout.PropertyField(_positionMode);
|
||||||
|
|
||||||
// Auto Scaling
|
// Auto Scaling
|
||||||
DrawInversedToggle(_ignoreCanvasScaler, s_ContentAutoScaling, () =>
|
DrawInversedToggle(_ignoreCanvasScaler, s_ContentAutoScaling, () =>
|
||||||
|
@ -522,7 +522,6 @@ namespace Coffee.UIExtensions
|
||||||
EditorGUIUtility.labelWidth = 100;
|
EditorGUIUtility.labelWidth = 100;
|
||||||
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_Enabled"));
|
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_Enabled"));
|
||||||
s_XYZMode = DrawFloatOrVector3Field(s_SerializedObject.FindProperty("m_Scale3D"), s_XYZMode);
|
s_XYZMode = DrawFloatOrVector3Field(s_SerializedObject.FindProperty("m_Scale3D"), s_XYZMode);
|
||||||
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_AbsoluteMode"));
|
|
||||||
DrawInversedToggle(s_SerializedObject.FindProperty("m_IgnoreCanvasScaler"),
|
DrawInversedToggle(s_SerializedObject.FindProperty("m_IgnoreCanvasScaler"),
|
||||||
s_ContentAutoScaling,
|
s_ContentAutoScaling,
|
||||||
() =>
|
() =>
|
||||||
|
@ -533,6 +532,7 @@ namespace Coffee.UIExtensions
|
||||||
.ToList()
|
.ToList()
|
||||||
.ForEach(x => x.transform.localScale = Vector3.one);
|
.ForEach(x => x.transform.localScale = Vector3.one);
|
||||||
});
|
});
|
||||||
|
EditorGUILayout.PropertyField(s_SerializedObject.FindProperty("m_PositionMode"));
|
||||||
EditorGUIUtility.labelWidth = labelWidth;
|
EditorGUIUtility.labelWidth = labelWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Coffee.UIExtensions
|
||||||
[ExecuteAlways]
|
[ExecuteAlways]
|
||||||
[RequireComponent(typeof(RectTransform))]
|
[RequireComponent(typeof(RectTransform))]
|
||||||
[RequireComponent(typeof(CanvasRenderer))]
|
[RequireComponent(typeof(CanvasRenderer))]
|
||||||
public class UIParticle : MaskableGraphic
|
public class UIParticle : MaskableGraphic, ISerializationCallbackReceiver
|
||||||
{
|
{
|
||||||
public enum MeshSharing
|
public enum MeshSharing
|
||||||
{
|
{
|
||||||
|
@ -30,10 +30,20 @@ namespace Coffee.UIExtensions
|
||||||
Replica
|
Replica
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PositionMode
|
||||||
|
{
|
||||||
|
Relative,
|
||||||
|
Absolute
|
||||||
|
}
|
||||||
|
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
internal bool m_IsTrail;
|
internal bool m_IsTrail;
|
||||||
|
|
||||||
|
[HideInInspector]
|
||||||
|
[SerializeField]
|
||||||
|
private bool m_AbsoluteMode;
|
||||||
|
|
||||||
[Tooltip("Particle effect scale")]
|
[Tooltip("Particle effect scale")]
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private Vector3 m_Scale3D = new Vector3(10, 10, 10);
|
private Vector3 m_Scale3D = new Vector3(10, 10, 10);
|
||||||
|
@ -64,13 +74,10 @@ namespace Coffee.UIExtensions
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private int m_GroupMaxId;
|
private int m_GroupMaxId;
|
||||||
|
|
||||||
|
[Tooltip("Relative: The particles will be emitted from the scaled position of ParticleSystem.\n" +
|
||||||
|
"Absolute: The particles will be emitted from the world position of ParticleSystem.")]
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
[Tooltip("Particle position mode.\n" +
|
private PositionMode m_PositionMode = PositionMode.Relative;
|
||||||
"Absolute Mode: The particles will be emitted from the ParticleSystem position.\n" +
|
|
||||||
" Move the UIParticle or ParticleSystem to move the particle.\n" +
|
|
||||||
"Relative Mode: The particles will be emitted from the scaled ParticleSystem position.\n" +
|
|
||||||
" Move the UIParticle to move the particle.")]
|
|
||||||
private bool m_AbsoluteMode = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This field uses the inverted value as "AutoScaling".
|
/// This field uses the inverted value as "AutoScaling".
|
||||||
|
@ -142,15 +149,24 @@ namespace Coffee.UIExtensions
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Particle position mode.
|
/// Particle position mode.
|
||||||
/// Absolute Mode: The particles will be emitted from the ParticleSystem position.
|
/// Relative: The particles will be emitted from the scaled position of the ParticleSystem.
|
||||||
/// Move the UIParticle or ParticleSystem to move the particle.
|
/// Absolute: The particles will be emitted from the world position of the ParticleSystem.
|
||||||
/// Relative Mode: The particles will be emitted from the scaled ParticleSystem position.
|
/// </summary>
|
||||||
/// Move the UIParticle to move the particle.
|
public PositionMode positionMode
|
||||||
|
{
|
||||||
|
get { return m_PositionMode; }
|
||||||
|
set { m_PositionMode = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Particle position mode.
|
||||||
|
/// Relative: The particles will be emitted from the scaled position of the ParticleSystem.
|
||||||
|
/// Absolute: The particles will be emitted from the world position of the ParticleSystem.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool absoluteMode
|
public bool absoluteMode
|
||||||
{
|
{
|
||||||
get { return m_AbsoluteMode; }
|
get { return m_PositionMode == PositionMode.Absolute; }
|
||||||
set { m_AbsoluteMode = value; }
|
set { positionMode = value ? PositionMode.Absolute : PositionMode.Relative; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -306,6 +322,19 @@ namespace Coffee.UIExtensions
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||||
|
{
|
||||||
|
m_AbsoluteMode = m_PositionMode == PositionMode.Absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||||
|
{
|
||||||
|
if (m_AbsoluteMode)
|
||||||
|
{
|
||||||
|
m_PositionMode = PositionMode.Absolute;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Play()
|
public void Play()
|
||||||
{
|
{
|
||||||
particles.Exec(p => p.Simulate(0, false, true));
|
particles.Exec(p => p.Simulate(0, false, true));
|
||||||
|
|
|
@ -185,7 +185,7 @@ namespace Coffee.UIExtensions
|
||||||
dstPos = dstPos.GetScaled(inverseScale, _uiParticle.scale3D.Inverse());
|
dstPos = dstPos.GetScaled(inverseScale, _uiParticle.scale3D.Inverse());
|
||||||
|
|
||||||
// Relative mode
|
// Relative mode
|
||||||
if (!_uiParticle.absoluteMode)
|
if (_uiParticle.positionMode == UIParticle.PositionMode.Relative)
|
||||||
{
|
{
|
||||||
var diff = _uiParticle.transform.position - psPos;
|
var diff = _uiParticle.transform.position - psPos;
|
||||||
diff.Scale(_uiParticle.scale3D - inverseScale);
|
diff.Scale(_uiParticle.scale3D - inverseScale);
|
||||||
|
|
|
@ -353,7 +353,7 @@ namespace Coffee.UIExtensions
|
||||||
Profiler.BeginSample("[UIParticleRenderer] Combine Mesh");
|
Profiler.BeginSample("[UIParticleRenderer] Combine Mesh");
|
||||||
if (_parent.canSimulate)
|
if (_parent.canSimulate)
|
||||||
{
|
{
|
||||||
if (_parent.absoluteMode)
|
if (_parent.positionMode == UIParticle.PositionMode.Absolute)
|
||||||
{
|
{
|
||||||
s_CombineInstances[0].transform =
|
s_CombineInstances[0].transform =
|
||||||
canvasRenderer.transform.worldToLocalMatrix
|
canvasRenderer.transform.worldToLocalMatrix
|
||||||
|
|
Loading…
Reference in New Issue