mirror of
https://github.com/maxartz15/UnitySerializedReferenceUI.git
synced 2024-11-22 07:35:36 +01:00
Added not supported types example.
Classes that has no empty parameters are not supported and not shown(activator can not create instances of them).
This commit is contained in:
parent
04c27fc3d4
commit
1e8f80077f
@ -51,6 +51,9 @@ public static class ManagedReferenceUtility
|
||||
// Skip abstract classes because they should not be instantiated
|
||||
if (type.IsAbstract)
|
||||
continue;
|
||||
// Skip types that has no public empty constructors (activator can not create them)
|
||||
if (type.IsClass && type.GetConstructor(Type.EmptyTypes) == null) // Structs still can be created (strangely)
|
||||
continue;
|
||||
// Filter types by provided filters if there is ones
|
||||
if (filters != null && filters.All(f => f == null || f.Invoke(type)) == false)
|
||||
continue;
|
||||
|
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
[Serializable]
|
||||
public struct AnimalStruct : IAnimal
|
||||
{
|
||||
public string name;
|
||||
public void Feed() => throw new NotImplementedException();
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c25ac56f032882a4b972b608e69230cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5be67cbd02bf42146a3ebb2790befebf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class ExampleOfNotSupportedTypes
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AnimalMonoBehaviour : MonoBehaviour, IAnimal
|
||||
{
|
||||
public void Feed() => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AnimalScriptableObject : ScriptableObject, IAnimal
|
||||
{
|
||||
public void Feed() => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class AnimalPrivateConstructor : IAnimal
|
||||
{
|
||||
private AnimalPrivateConstructor(){}
|
||||
public void Feed() => throw new NotImplementedException();
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1060d26326c424a468bfd669381a0745
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -199,12 +199,9 @@ MonoBehaviour:
|
||||
numberOfBones: 0
|
||||
Tag:
|
||||
00000005:
|
||||
type: {class: RedApe, ns: , asm: SerializedReferenceExample}
|
||||
type: {class: AnimalStruct, ns: , asm: SerializedReferenceExample}
|
||||
data:
|
||||
age: 0
|
||||
food: {fileID: 0}
|
||||
numberOfBones: 0
|
||||
Tag:
|
||||
name:
|
||||
00000006:
|
||||
type: {class: BlackApe, ns: , asm: SerializedReferenceExample}
|
||||
data:
|
||||
|
Loading…
Reference in New Issue
Block a user