From 406db6704fe1c3a577bd37e4281a70021cb9085c Mon Sep 17 00:00:00 2001 From: honzapatCZ Date: Sun, 7 Mar 2021 11:30:18 +0100 Subject: [PATCH] Now its an editor option --- .../CustomEditors/Editors/GenericEditor.cs | 16 ++++++------ Source/Editor/Options/GeneralOptions.cs | 25 +++++++++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Source/Editor/CustomEditors/Editors/GenericEditor.cs b/Source/Editor/CustomEditors/Editors/GenericEditor.cs index f3569bd65..f430dbf61 100644 --- a/Source/Editor/CustomEditors/Editors/GenericEditor.cs +++ b/Source/Editor/CustomEditors/Editors/GenericEditor.cs @@ -173,16 +173,16 @@ namespace FlaxEditor.CustomEditors.Editors return string.Compare(Display.Group, other.Display.Group, StringComparison.InvariantCulture); } - // By declaration order - if (Info.MetadataToken > other.Info.MetadataToken) - return 1; - else if (Info.MetadataToken < other.Info.MetadataToken) - return -1; - else + if(Editor.Instance.Options.Options.General.ScritpMembersOrder == Options.GeneralOptions.MembersOrder.Declaration) { - // 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; } + // By name + return string.Compare(Info.Name, other.Info.Name, StringComparison.InvariantCulture); } return 0; diff --git a/Source/Editor/Options/GeneralOptions.cs b/Source/Editor/Options/GeneralOptions.cs index 85174030f..2a6a4c0b5 100644 --- a/Source/Editor/Options/GeneralOptions.cs +++ b/Source/Editor/Options/GeneralOptions.cs @@ -68,6 +68,24 @@ namespace FlaxEditor.Options CompileScripts, } + /// + /// Order of script members show in editor + /// + public enum MembersOrder + { + /// + /// Shows properties/fields in alphabetical order + /// + [Tooltip("Shows properties/fields in alphabetical order")] + Alphabetical, + + /// + /// Shows properties/fields in declaration order + /// + [Tooltip("Shows properties/fields in declaration order")] + Declaration + } + /// /// Gets or sets the scene to load on editor startup. /// @@ -116,6 +134,13 @@ namespace FlaxEditor.Options [EditorDisplay("Scripting", "Force Script Compilation On Startup"), EditorOrder(501), Tooltip("Determines whether automatically compile game scripts before starting the editor.")] public bool ForceScriptCompilationOnStartup { get; set; } = true; + /// + /// Gets or sets a value indicating whether automatically save the Visual Script asset editors when starting the play mode in editor. + /// + [DefaultValue(true)] + [EditorDisplay("Scripting", "Scritp Members Order"), EditorOrder(503), Tooltip("Sets the order of script properties/fields")] + public MembersOrder ScritpMembersOrder { get; set; } = MembersOrder.Alphabetical; + /// /// Gets or sets a value indicating whether automatically save the Visual Script asset editors when starting the play mode in editor. ///