Skip to content

Commit

Permalink
feat: support for changing rendering orders
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Aug 28, 2020
1 parent 2fb5d91 commit 745d4a5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Packages/UIParticle/Scripts/Editor/UIParticleEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ internal class UIParticleEditor : GraphicEditor
private SerializedProperty _spScale;
private SerializedProperty _spIgnoreCanvasScaler;
private SerializedProperty _spAnimatableProperties;

private ReorderableList _ro;
private bool _xyzMode;

private static readonly List<string> s_MaskablePropertyNames = new List<string>
Expand All @@ -44,6 +46,27 @@ protected override void OnEnable()
_spScale = serializedObject.FindProperty("m_Scale");
_spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler");
_spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");

var sp = serializedObject.FindProperty("m_Particles");
_ro = new ReorderableList(sp.serializedObject, sp, true, true, false, false);
_ro.elementHeight = EditorGUIUtility.singleLineHeight + 4;
_ro.drawElementCallback = (rect, index, active, focused) =>
{
rect.y += 1;
rect.height = EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, sp.GetArrayElementAtIndex(index), GUIContent.none);
};
_ro.drawHeaderCallback += rect =>
{
EditorGUI.LabelField(new Rect(rect.x, rect.y, 150, rect.height), "Rendering Order");

if (!GUI.Button(new Rect(rect.width - 80, rect.y - 1, 80, rect.height), "Reset", EditorStyles.miniButton)) return;

foreach (UIParticle t in targets)
{
t.RefreshParticles();
}
};
}

/// <summary>
Expand All @@ -69,6 +92,7 @@ public override void OnInspectorGUI()
// AnimatableProperties
AnimatedPropertiesEditor.DrawAnimatableProperties(_spAnimatableProperties, current.material);

_ro.DoLayoutList();

// Does the shader support UI masks?
if (current.maskable && current.GetComponentInParent<Mask>())
Expand Down

0 comments on commit 745d4a5

Please sign in to comment.