Merge pull request #4 from mackysoft/feature/struct-support

Add struct support
This commit is contained in:
Makihiro 2021-12-31 11:20:23 +09:00 committed by GitHub
commit f7d6aee382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 2 deletions

View File

@ -63,7 +63,6 @@ namespace MackySoft.SerializeReferenceExtensions.Editor {
Type baseType = property.GetManagedReferenceFieldType(); Type baseType = property.GetManagedReferenceFieldType();
var popup = new AdvancedTypePopup( var popup = new AdvancedTypePopup(
TypeCache.GetTypesDerivedFrom(baseType).Where(p => TypeCache.GetTypesDerivedFrom(baseType).Where(p =>
p.IsClass &&
(p.IsPublic || p.IsNestedPublic) && (p.IsPublic || p.IsNestedPublic) &&
!p.IsAbstract && !p.IsAbstract &&
!p.IsGenericType && !p.IsGenericType &&

View File

@ -334,6 +334,7 @@ MonoBehaviour:
- id: 1 - id: 1
- id: 2 - id: 2
- id: 3 - id: 3
- id: 4
references: references:
version: 1 version: 1
00000000: 00000000:
@ -348,6 +349,8 @@ MonoBehaviour:
type: {class: Example/NestedCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp} type: {class: Example/NestedCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp}
00000003: 00000003:
type: {class: AddTypeMenuCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp} type: {class: AddTypeMenuCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp}
00000004:
type: {class: StructCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp}
--- !u!4 &1098750747 --- !u!4 &1098750747
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -69,5 +69,12 @@ namespace MackySoft.SerializeReferenceExtensions.Example {
} }
} }
[Serializable]
public struct StructCommand : ICommand {
public void Execute () {
Debug.Log("Execute StructCommand");
}
}
} }
#endif #endif

View File

@ -111,13 +111,19 @@ public class AddTypeMenuCommand : ICommand {
Debug.Log("Execute AddTypeMenuCommand"); Debug.Log("Execute AddTypeMenuCommand");
} }
} }
[Serializable]
public struct StructCommand : ICommand {
public void Execute () {
Debug.Log("Execute StructCommand");
}
}
``` ```
#### Supported Types #### Supported Types
The `SubclassSelector` attribute supports types that meet the following conditions. The `SubclassSelector` attribute supports types that meet the following conditions.
- Class
- Public - Public
- Not abstract - Not abstract
- Not generic - Not generic