mirror of
https://github.com/maxartz15/UnitySerializedReferenceUI.git
synced 2025-06-30 16:16:08 +02:00
split runtime and editor
This commit is contained in:
14
Runtime/Core/SerializeReferenceTypeRestrictionFilters.cs
Normal file
14
Runtime/Core/SerializeReferenceTypeRestrictionFilters.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
public static class SerializeReferenceTypeRestrictionFilters
|
||||
{
|
||||
public static Func<Type, bool> TypeIsNotSubclassOrEqualOrHasInterface(Type[] types) => type =>
|
||||
TypeIsSubclassOrEqualOrHasInterface(types).Invoke(type) == false;
|
||||
|
||||
public static Func<Type, bool> TypeIsSubclassOrEqualOrHasInterface(Type[] types) => type =>
|
||||
types.Any(e => e.IsInterface ? TypeHasInterface(type, e) : TypeIsSubclassOrEqual(type, e));
|
||||
|
||||
public static bool TypeIsSubclassOrEqual(Type type, Type comparator) => type.IsSubclassOf(comparator) || type == comparator;
|
||||
public static bool TypeHasInterface(this Type type, Type comparator) => type.GetInterface(comparator.ToString()) != null;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b71802ffed0a18d43901672fcbf668c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user