diff --git a/Source/Editor/Content/Items/VisualScriptItem.cs b/Source/Editor/Content/Items/VisualScriptItem.cs
index fd23887ec..22f1d75cc 100644
--- a/Source/Editor/Content/Items/VisualScriptItem.cs
+++ b/Source/Editor/Content/Items/VisualScriptItem.cs
@@ -75,6 +75,8 @@ namespace FlaxEditor.Content
}
}
+ public int MetadataToken => 0;
+
///
public bool HasAttribute(Type attributeType, bool inherit)
{
@@ -195,6 +197,8 @@ namespace FlaxEditor.Content
///
public ScriptType ValueType => _returnType;
+ public int MetadataToken => 0;
+
///
public bool HasAttribute(Type attributeType, bool inherit)
{
diff --git a/Source/Editor/CustomEditors/Editors/GenericEditor.cs b/Source/Editor/CustomEditors/Editors/GenericEditor.cs
index ed6d88e9e..f3569bd65 100644
--- a/Source/Editor/CustomEditors/Editors/GenericEditor.cs
+++ b/Source/Editor/CustomEditors/Editors/GenericEditor.cs
@@ -173,8 +173,16 @@ namespace FlaxEditor.CustomEditors.Editors
return string.Compare(Display.Group, other.Display.Group, StringComparison.InvariantCulture);
}
- // By name
- return string.Compare(Info.Name, other.Info.Name, StringComparison.InvariantCulture);
+ // By declaration order
+ if (Info.MetadataToken > other.Info.MetadataToken)
+ return 1;
+ else if (Info.MetadataToken < other.Info.MetadataToken)
+ return -1;
+ else
+ {
+ // By name
+ return string.Compare(Info.Name, other.Info.Name, StringComparison.InvariantCulture);
+ }
}
return 0;
diff --git a/Source/Editor/Scripting/ScriptType.cs b/Source/Editor/Scripting/ScriptType.cs
index 53c84a1b5..bca6ccf40 100644
--- a/Source/Editor/Scripting/ScriptType.cs
+++ b/Source/Editor/Scripting/ScriptType.cs
@@ -40,6 +40,22 @@ namespace FlaxEditor.Scripting
///
public string Name => _managed?.Name ?? _custom?.Name;
+ ///
+ /// Gets a metadata token for sorting so it may not be the actual token.
+ ///
+ public int MetadataToken
+ {
+ get
+ {
+ if (_managed != null && IsProperty)
+ {
+ ScriptMemberInfo finfo = DeclaringType.GetField(string.Format("<{0}>k__BackingField", Name), BindingFlags.Instance | BindingFlags.NonPublic);
+ return finfo.MetadataToken;
+ }
+ return _managed?.MetadataToken ?? _custom?.MetadataToken ?? 0;
+ }
+ }
+
///
/// Gets a value indicating whether the type is declared public.
///
@@ -1444,6 +1460,11 @@ namespace FlaxEditor.Scripting
///
string Name { get; }
+ ///
+ /// Gets a metadata token for sorting so it may not be the actual token.
+ ///
+ int MetadataToken { get; }
+
///
/// Gets a value indicating whether the type is declared public.
///