Skip to content

Commit f7d6aee

Browse files
authored
Merge pull request #4 from mackysoft/feature/struct-support
Add struct support
2 parents 024a9cd + cba28ca commit f7d6aee

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Editor/SubclassSelectorDrawer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ TypePopupCache GetTypePopup (SerializedProperty property) {
6363
Type baseType = property.GetManagedReferenceFieldType();
6464
var popup = new AdvancedTypePopup(
6565
TypeCache.GetTypesDerivedFrom(baseType).Where(p =>
66-
p.IsClass &&
6766
(p.IsPublic || p.IsNestedPublic) &&
6867
!p.IsAbstract &&
6968
!p.IsGenericType &&

Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Example/Example.unity

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ MonoBehaviour:
334334
- id: 1
335335
- id: 2
336336
- id: 3
337+
- id: 4
337338
references:
338339
version: 1
339340
00000000:
@@ -348,6 +349,8 @@ MonoBehaviour:
348349
type: {class: Example/NestedCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp}
349350
00000003:
350351
type: {class: AddTypeMenuCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp}
352+
00000004:
353+
type: {class: StructCommand, ns: MackySoft.SerializeReferenceExtensions.Example, asm: Assembly-CSharp}
351354
--- !u!4 &1098750747
352355
Transform:
353356
m_ObjectHideFlags: 0

Assets/MackySoft/MackySoft.SerializeReferenceExtensions/Example/ExampleAssets/Scripts/Runtime/Example.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,12 @@ public void Execute () {
6969
}
7070
}
7171

72+
[Serializable]
73+
public struct StructCommand : ICommand {
74+
public void Execute () {
75+
Debug.Log("Execute StructCommand");
76+
}
77+
}
78+
7279
}
7380
#endif

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,19 @@ public class AddTypeMenuCommand : ICommand {
111111
Debug.Log("Execute AddTypeMenuCommand");
112112
}
113113
}
114+
115+
[Serializable]
116+
public struct StructCommand : ICommand {
117+
public void Execute () {
118+
Debug.Log("Execute StructCommand");
119+
}
120+
}
114121
```
115122

116123
#### Supported Types
117124

118125
The `SubclassSelector` attribute supports types that meet the following conditions.
119126

120-
- Class
121127
- Public
122128
- Not abstract
123129
- Not generic

0 commit comments

Comments
 (0)