From b9ad9838aeeb7a26d2e4c57602d3ea0708974da2 Mon Sep 17 00:00:00 2001 From: mackysoft Date: Fri, 31 Dec 2021 11:03:50 +0900 Subject: [PATCH 1/3] Removed class constraints. Removed class constraints. This allows the use of structs. --- .../Editor/SubclassSelectorDrawer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs index 3525a37..0e5f746 100644 --- a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs +++ b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs @@ -63,7 +63,6 @@ namespace MackySoft.SerializeReferenceExtensions.Editor { Type baseType = property.GetManagedReferenceFieldType(); var popup = new AdvancedTypePopup( TypeCache.GetTypesDerivedFrom(baseType).Where(p => - p.IsClass && (p.IsPublic || p.IsNestedPublic) && !p.IsAbstract && !p.IsGenericType && From e7d200c0910b4e567482851a0db948ab2aa891ab Mon Sep 17 00:00:00 2001 From: mackysoft Date: Fri, 31 Dec 2021 11:04:05 +0900 Subject: [PATCH 2/3] Update example --- .../Example/Example.unity | 3 +++ .../Example/ExampleAssets/Scripts/Runtime/Example.cs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Example/Example.unity b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Example/Example.unity index 7de6c63..86338ed 100644 --- a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Example/Example.unity +++ b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Example/Example.unity @@ -334,6 +334,7 @@ MonoBehaviour: - id: 1 - id: 2 - id: 3 + - id: 4 references: version: 1 00000000: @@ -348,6 +349,8 @@ MonoBehaviour: type: {class: Example/NestedCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp} 00000003: type: {class: AddTypeMenuCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp} + 00000004: + type: {class: StructCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp} --- !u!4 &1098750747 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Example/ExampleAssets/Scripts/Runtime/Example.cs b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Example/ExampleAssets/Scripts/Runtime/Example.cs index 570c109..301e54d 100644 --- a/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Example/ExampleAssets/Scripts/Runtime/Example.cs +++ b/Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Example/ExampleAssets/Scripts/Runtime/Example.cs @@ -69,5 +69,12 @@ namespace MackySoft.SerializeReferenceExtensions.Example { } } + [Serializable] + public struct StructCommand : ICommand { + public void Execute () { + Debug.Log("Execute StructCommand"); + } + } + } #endif \ No newline at end of file From cba28ca317ff18552be8291693f2bc57ec7e1682 Mon Sep 17 00:00:00 2001 From: mackysoft Date: Fri, 31 Dec 2021 11:04:21 +0900 Subject: [PATCH 3/3] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7c497e4..14a973d 100644 --- a/README.md +++ b/README.md @@ -111,13 +111,19 @@ public class AddTypeMenuCommand : ICommand { Debug.Log("Execute AddTypeMenuCommand"); } } + +[Serializable] +public struct StructCommand : ICommand { + public void Execute () { + Debug.Log("Execute StructCommand"); + } +} ``` #### Supported Types The `SubclassSelector` attribute supports types that meet the following conditions. -- Class - Public - Not abstract - Not generic