diff --git a/Runtime/Internal/Attributes/ComponentHandlerAttribute.cs b/Runtime/Internal/Attributes/ComponentHandlerAttribute.cs index 5827d57b..a3a82a64 100644 --- a/Runtime/Internal/Attributes/ComponentHandlerAttribute.cs +++ b/Runtime/Internal/Attributes/ComponentHandlerAttribute.cs @@ -7,17 +7,20 @@ namespace XCharts.Runtime { public readonly Type handler; public readonly bool allowMultiple = true; + public readonly int order = 3; - public ComponentHandlerAttribute(Type handler) + public ComponentHandlerAttribute(Type handler, int order = 3) { this.handler = handler; this.allowMultiple = true; + this.order = order; } - public ComponentHandlerAttribute(Type handler, bool allowMultiple) + public ComponentHandlerAttribute(Type handler, bool allowMultiple, int order = 3) { this.handler = handler; this.allowMultiple = allowMultiple; + this.order = order; } } } \ No newline at end of file diff --git a/Runtime/Internal/BaseChart.Component.cs b/Runtime/Internal/BaseChart.Component.cs index ac19ddc6..2e1d99a8 100644 --- a/Runtime/Internal/BaseChart.Component.cs +++ b/Runtime/Internal/BaseChart.Component.cs @@ -123,9 +123,11 @@ namespace XCharts.Runtime var handler = (MainComponentHandler)Activator.CreateInstance(attrubte.handler); handler.attribute = attrubte; handler.chart = this; + handler.order = attrubte.order; handler.SetComponent(component); component.handler = handler; m_ComponentHandlers.Add(handler); + m_ComponentHandlers.Sort((a, b) => { return a.order.CompareTo(b.order); }); } public bool RemoveChartComponent(int index = 0) diff --git a/Runtime/Internal/Basic/MainComponent.cs b/Runtime/Internal/Basic/MainComponent.cs index d36f9a87..9bc4adca 100644 --- a/Runtime/Internal/Basic/MainComponent.cs +++ b/Runtime/Internal/Basic/MainComponent.cs @@ -88,6 +88,7 @@ namespace XCharts.Runtime public abstract class MainComponentHandler { + public int order { get; internal set; } public BaseChart chart { get; internal set; } public ComponentHandlerAttribute attribute { get; internal set; }