From 431a28fe190fe78aa9f265b444d816442c5f7427 Mon Sep 17 00:00:00 2001 From: Zae Date: Tue, 23 Aug 2022 01:23:45 +0800 Subject: C#: Add grouping attributes for properties. --- .../Core/Attributes/ExportCategoryAttribute.cs | 22 +++++++++++++++++++ .../Core/Attributes/ExportGroupAttribute.cs | 25 ++++++++++++++++++++++ .../Core/Attributes/ExportSubgroupAttribute.cs | 25 ++++++++++++++++++++++ .../glue/GodotSharp/GodotSharp/GodotSharp.csproj | 3 +++ 4 files changed, 75 insertions(+) create mode 100644 modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportCategoryAttribute.cs create mode 100644 modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportGroupAttribute.cs create mode 100644 modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportSubgroupAttribute.cs (limited to 'modules/mono/glue/GodotSharp') diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportCategoryAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportCategoryAttribute.cs new file mode 100644 index 0000000000..101e56f8d3 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportCategoryAttribute.cs @@ -0,0 +1,22 @@ +using System; + +namespace Godot +{ + /// + /// Define a new category for the following exported properties. This helps to organize properties in the Inspector dock. + /// + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public sealed class ExportCategoryAttribute : Attribute + { + private string name; + + /// + /// Define a new category for the following exported properties. + /// + /// The name of the category. + public ExportCategoryAttribute(string name) + { + this.name = name; + } + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportGroupAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportGroupAttribute.cs new file mode 100644 index 0000000000..3bd532cec1 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportGroupAttribute.cs @@ -0,0 +1,25 @@ +using System; + +namespace Godot +{ + /// + /// Define a new group for the following exported properties. This helps to organize properties in the Inspector dock. + /// + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public sealed class ExportGroupAttribute : Attribute + { + private string name; + private string prefix; + + /// + /// Define a new group for the following exported properties. + /// + /// The name of the group. + /// If provided, the group would make group to only consider properties that have this prefix. + public ExportGroupAttribute(string name, string prefix = "") + { + this.name = name; + this.prefix = prefix; + } + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportSubgroupAttribute.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportSubgroupAttribute.cs new file mode 100644 index 0000000000..2ae6eb0b68 --- /dev/null +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Attributes/ExportSubgroupAttribute.cs @@ -0,0 +1,25 @@ +using System; + +namespace Godot +{ + /// + /// Define a new subgroup for the following exported properties. This helps to organize properties in the Inspector dock. + /// + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public sealed class ExportSubgroupAttribute : Attribute + { + private string name; + private string prefix; + + /// + /// Define a new subgroup for the following exported properties. This helps to organize properties in the Inspector dock. + /// + /// The name of the subgroup. + /// If provided, the subgroup would make group to only consider properties that have this prefix. + public ExportSubgroupAttribute(string name, string prefix = "") + { + this.name = name; + this.prefix = prefix; + } + } +} diff --git a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj index 111920ecf6..f0d6748b73 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj +++ b/modules/mono/glue/GodotSharp/GodotSharp/GodotSharp.csproj @@ -53,6 +53,9 @@ + + + -- cgit v1.2.3