split runtime and editor

This commit is contained in:
max
2022-12-28 13:55:36 +01:00
parent b9472d59b4
commit a0fa2c9b36
36 changed files with 43 additions and 7 deletions

8
Runtime/Attributes.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c962b02723999754ba9b137d407b5ec0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
using System;
using UnityEngine;
[AttributeUsage(AttributeTargets.Field)]
public class SerializeReferenceButtonAttribute : PropertyAttribute
{
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c64e0f68b41b48939c9b98cc29a19b20
timeCreated: 1579584059

View File

@ -0,0 +1,8 @@
using System;
using UnityEngine;
[AttributeUsage(AttributeTargets.Field)]
public class SerializeReferenceMenuAttribute : PropertyAttribute
{
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4f1c372fa681cf146973df30a0d969fd
timeCreated: 1579584059

View File

@ -0,0 +1,10 @@
using System;
using UnityEngine;
/// None of this types or interface types are valid.
[AttributeUsage(AttributeTargets.Field)]
public class SerializeReferenceUIRestrictionExcludeTypes : PropertyAttribute
{
public readonly Type[] Types;
public SerializeReferenceUIRestrictionExcludeTypes(params Type[] types) => Types = types;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ff5f6060287437048acba59e670cd000
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
using System;
using UnityEngine;
/// Any of this types or interface types are valid. And only this types can be presented.
[AttributeUsage(AttributeTargets.Field)]
public class SerializeReferenceUIRestrictionIncludeTypes : PropertyAttribute
{
public readonly Type[] Types;
public SerializeReferenceUIRestrictionIncludeTypes(params Type[] types) => Types = types;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6d10fb8315984ef458e4129191b17931
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Reflection;
public static class SerializedReferenceUIDefaultTypeRestrictions
{
public static IEnumerable<Func<Type, bool>> GetAllBuiltInTypeRestrictions(FieldInfo fieldInfo)
{
var result = new List<Func<Type, bool>>();
var attributeObjects = fieldInfo.GetCustomAttributes(false);
foreach (var attributeObject in attributeObjects)
{
switch (attributeObject)
{
case SerializeReferenceUIRestrictionIncludeTypes includeTypes:
result.Add(SerializeReferenceTypeRestrictionFilters.TypeIsSubclassOrEqualOrHasInterface(includeTypes.Types));
continue;
case SerializeReferenceUIRestrictionExcludeTypes excludeTypes:
result.Add(SerializeReferenceTypeRestrictionFilters.TypeIsNotSubclassOrEqualOrHasInterface(excludeTypes.Types));
continue;
}
}
return result;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95f44dc0cd315cf4988029eb8618aa02
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Runtime/Core.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dedc3ebcef4e16146b965988c96d2f1c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b71802ffed0a18d43901672fcbf668c9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,14 @@
{
"name": "Textus.SerializeReferenceUI",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 73106583b323919458c1e05166706ce3
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: