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:
8
Runtime/Attributes/SerializeReferenceButtonAttribute.cs
Normal file
8
Runtime/Attributes/SerializeReferenceButtonAttribute.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class SerializeReferenceButtonAttribute : PropertyAttribute
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c64e0f68b41b48939c9b98cc29a19b20
|
||||
timeCreated: 1579584059
|
8
Runtime/Attributes/SerializeReferenceMenuAttribute.cs
Normal file
8
Runtime/Attributes/SerializeReferenceMenuAttribute.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field)]
|
||||
public class SerializeReferenceMenuAttribute : PropertyAttribute
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f1c372fa681cf146973df30a0d969fd
|
||||
timeCreated: 1579584059
|
@ -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;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff5f6060287437048acba59e670cd000
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -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;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d10fb8315984ef458e4129191b17931
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95f44dc0cd315cf4988029eb8618aa02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user