Major refactor.

Core now formed and contains all useful utility to create custom ui with restrictions.
Many methods was extracted from different classes and moved to core.

Undo is now supported(because unity's undo bug seems to be fixed).

Example now moved into same level separate folder.
This commit is contained in:
TextusGames
2020-05-16 20:15:24 +03:00
parent f47dd5d350
commit eeaadfc569
65 changed files with 138 additions and 86 deletions
Assets/Textus
SerializeReferenceUI
SerializeReferenceUIExample.meta
SerializeReferenceUIExample

@ -0,0 +1,95 @@
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Object = UnityEngine.Object;
public static class ManagedReferenceUtility
{
/// Creates instance of passed type and assigns it to managed reference
public static object AssignNewInstanceOfTypeToManagedReference(this SerializedProperty serializedProperty, Type type)
{
var instance = Activator.CreateInstance(type);
serializedProperty.serializedObject.Update();
serializedProperty.managedReferenceValue = instance;
serializedProperty.serializedObject.ApplyModifiedProperties();
return instance;
}
/// Sets managed reference to null
public static void SetManagedReferenceToNull(this SerializedProperty serializedProperty)
{
serializedProperty.serializedObject.Update();
serializedProperty.managedReferenceValue = null;
serializedProperty.serializedObject.ApplyModifiedProperties();
}
/// Collects appropriate types based on managed reference field type and filters. Filters all derive
public static IEnumerable<Type> GetAppropriateTypesForAssigningToManagedReference(this SerializedProperty property, List<Func<Type, bool>> filters = null)
{
var fieldType = property.GetManagedReferenceFieldType();
return GetAppropriateTypesForAssigningToManagedReference(fieldType, filters);
}
/// Filters derived types of field typ parameter and finds ones whose are compatible with managed reference and filters.
public static IEnumerable<Type> GetAppropriateTypesForAssigningToManagedReference(Type fieldType, List<Func<Type, bool>> filters = null)
{
var appropriateTypes = new List<Type>();
// Get and filter all appropriate types
var derivedTypes = TypeCache.GetTypesDerivedFrom(fieldType);
foreach (var type in derivedTypes)
{
// Skips unity engine Objects (because they are not serialized by SerializeReference)
if (type.IsSubclassOf(typeof(Object)))
continue;
// Skip abstract classes because they should not be instantiated
if (type.IsAbstract)
continue;
// Filter types by provided filters if there is ones
if (filters != null && filters.All(f => f == null || f.Invoke(type)) == false)
continue;
appropriateTypes.Add(type);
}
return appropriateTypes;
}
/// Gets real type of managed reference
public static Type GetManagedReferenceFieldType(this SerializedProperty property)
{
var realPropertyType = GetRealTypeFromTypename(property.managedReferenceFieldTypename);
if (realPropertyType != null)
return realPropertyType;
Debug.LogError($"Can not get field type of managed reference : {property.managedReferenceFieldTypename}");
return null;
}
/// Gets real type of managed reference's field typeName
public static Type GetRealTypeFromTypename(string stringType)
{
var names = GetSplitNamesFromTypename(stringType);
var realType = Type.GetType($"{names.ClassName}, {names.AssemblyName}");
return realType;
}
/// Get assembly and class names from typeName
public static (string AssemblyName, string ClassName) GetSplitNamesFromTypename(string typename)
{
if (string.IsNullOrEmpty(typename))
return ("","");
var typeSplitString = typename.Split(char.Parse(" "));
var typeClassName = typeSplitString[1];
var typeAssemblyName = typeSplitString[0];
return (typeAssemblyName, typeClassName);
}
}
#endif

@ -9,7 +9,7 @@ using UnityEngine;
public static class SerializeReferenceGenericSelectionMenu
{
/// Purpose.
/// This is generic selection menu.
/// This is generic selection menu.
/// Filtering.
/// You can add substring filter here to filter by search string.
/// As well ass type or interface restrictions.
@ -22,72 +22,39 @@ public static class SerializeReferenceGenericSelectionMenu
context.ShowAsContext();
}
private static void FillContextMenu(IEnumerable<Func<Type, bool>> enumerableFilters, GenericMenu contextMenu, SerializedProperty property)
{
var filters = enumerableFilters.ToList();// Prevents possible multiple enumerations
// Adds "Make Null" menu command
contextMenu.AddItem(new GUIContent("Null"), false, () => MakeSerializedPropertyNull(property));
// Find real type of managed reference
var realPropertyType = SerializeReferenceTypeNameUtility.GetRealTypeFromTypename(property.managedReferenceFieldTypename);
if (realPropertyType == null)
{
Debug.LogError("Can not get type from");
return;
}
contextMenu.AddItem(new GUIContent("Null"), false, property.SetManagedReferenceToNull);
// Get and filter all appropriate types
var types = TypeCache.GetTypesDerivedFrom(realPropertyType);
foreach (var type in types)
{
// Skips unity engine Objects (because they are not serialized by SerializeReference)
if(type.IsSubclassOf(typeof(UnityEngine.Object)))
continue;
// Skip abstract classes because they should not be instantiated
if(type.IsAbstract)
continue;
// Filter types by provided filters if there is ones
if (FilterTypeByFilters(filters, type) == false)
continue;
AddItemToContextMenu(type, contextMenu, property);
}
}
private static void MakeSerializedPropertyNull(SerializedProperty serializedProperty)
{
serializedProperty.serializedObject.Update();
serializedProperty.managedReferenceValue = null;
serializedProperty.serializedObject.ApplyModifiedPropertiesWithoutUndo(); // undo is bugged for now
// Collects appropriate types
var appropriateTypes = property.GetAppropriateTypesForAssigningToManagedReference(filters);
// Adds appropriate types to menu
foreach (var appropriateType in appropriateTypes)
AddItemToContextMenu(appropriateType, contextMenu, property);
}
private static void AddItemToContextMenu(Type type, GenericMenu genericMenuContext, SerializedProperty property)
{
var assemblyName = type.Assembly.ToString().Split('(', ',')[0];
var entryName = type + " ( " + assemblyName + " )";
genericMenuContext.AddItem(new GUIContent(entryName), false, AssignNewInstanceOfType, new AssignInstanceGenericMenuParameter(type, property));
genericMenuContext.AddItem(new GUIContent(entryName), false, AssignNewInstanceCommand, new GenericMenuParameterForAssignInstanceCommand(type, property));
}
private static void AssignNewInstanceOfType(object objectGenericMenuParameter )
private static void AssignNewInstanceCommand(object objectGenericMenuParameter )
{
var parameter = (AssignInstanceGenericMenuParameter) objectGenericMenuParameter;
var parameter = (GenericMenuParameterForAssignInstanceCommand) objectGenericMenuParameter;
var type = parameter.Type;
var property = parameter.Property;
var instance = Activator.CreateInstance(type);
property.serializedObject.Update();
property.managedReferenceValue = instance;
property.serializedObject.ApplyModifiedPropertiesWithoutUndo(); // undo is bugged for now
}
private static bool FilterTypeByFilters (IEnumerable<Func<Type,bool>> filters, Type type) =>
filters.All(f => f == null || f.Invoke(type));
property.AssignNewInstanceOfTypeToManagedReference(type);
}
private readonly struct AssignInstanceGenericMenuParameter
private readonly struct GenericMenuParameterForAssignInstanceCommand
{
public AssignInstanceGenericMenuParameter(Type type, SerializedProperty property)
public GenericMenuParameterForAssignInstanceCommand(Type type, SerializedProperty property)
{
Type = type;
Property = property;

@ -1,24 +0,0 @@
using System;
/// This utility exists, because serialize reference managed reference typename returns combined string
/// and not data class that contains separate strings for assembly name and for class name (and possibly namespace name)
public static class SerializeReferenceTypeNameUtility
{
public static Type GetRealTypeFromTypename(string stringType)
{
var names = GetSplitNamesFromTypename(stringType);
var realType = Type.GetType($"{names.ClassName}, {names.AssemblyName}");
return realType;
}
public static (string AssemblyName, string ClassName) GetSplitNamesFromTypename(string typename)
{
if (string.IsNullOrEmpty(typename))
return ("","");
var typeSplitString = typename.Split(char.Parse(" "));
var typeClassName = typeSplitString[1];
var typeAssemblyName = typeSplitString[0];
return (typeAssemblyName, typeClassName);
}
}

@ -1,4 +1,4 @@
using System;
 using System;
using System.Linq;
public static class SerializeReferenceTypeRestrictionFilters

@ -20,7 +20,7 @@ public class SerializeReferenceButtonAttributeDrawer : PropertyDrawer
var labelPosition = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.LabelField(labelPosition, label);
var typeRestrictions = SerializedReferenceUIBuiltInTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo);
var typeRestrictions = SerializedReferenceUIDefaultTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo);
property.DrawSelectionButtonForManagedReference(position, typeRestrictions);
EditorGUI.PropertyField(position, property, GUIContent.none, true);

@ -15,7 +15,7 @@ public class SerializeReferenceMenuAttributeDrawer : PropertyDrawer
{
EditorGUI.BeginProperty(position, label, property);
var typeRestrictions = SerializedReferenceUIBuiltInTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo);
var typeRestrictions = SerializedReferenceUIDefaultTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo);
property.ShowContextMenuForManagedReferenceOnMouseMiddleButton(position, typeRestrictions);
EditorGUI.PropertyField(position, property, true);

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 375e18944bf750b45b54b9715b23432a
guid: 3fbe55d72b5fd59459fdb52e0f301ea1
folderAsset: yes
DefaultImporter:
externalObjects: {}

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: f124bd3bbd4e5e44882fcc7ca4bbfd89
guid: c0c77910f7962a14cb85132596cb8d24
folderAsset: yes
DefaultImporter:
externalObjects: {}

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Reflection;
public static class SerializedReferenceUIBuiltInTypeRestrictions
public static class SerializedReferenceUIDefaultTypeRestrictions
{
public static IEnumerable<Func<Type, bool>> GetAllBuiltInTypeRestrictions(FieldInfo fieldInfo)
{

@ -31,7 +31,7 @@ public static class SerializeReferenceInspectorButton
GUI.backgroundColor = backgroundColor;
var names = SerializeReferenceTypeNameUtility.GetSplitNamesFromTypename(property.managedReferenceFullTypename);
var names = ManagedReferenceUtility.GetSplitNamesFromTypename(property.managedReferenceFullTypename);
var className = string.IsNullOrEmpty(names.ClassName) ? "Null (Assign)" : names.ClassName;
var assemblyName = names.AssemblyName;
if (GUI.Button(buttonPosition, new GUIContent(className, className + " ( "+ assemblyName +" )" )))

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

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

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

@ -1,42 +0,0 @@
using System;
using UnityEngine;
[Serializable]
public class AnimalBase : IAnimal
{
[SerializeField] protected float age;
public GameObject food;
public virtual void Feed()
{
Debug.Log("Thanks");
}
}
[Serializable]
public class AnimalChild : AnimalBase {}
[Serializable]
public abstract class AnimalGrandChildAbstract : AnimalBase
{
public string someString;
}
[Serializable]
public class AbstractAnimalGrandChild : AnimalGrandChildAbstract {}
[Serializable]
public abstract class AbstractAnimal : IAnimal
{
[SerializeField] protected float age;
public GameObject food;
public virtual void Feed()
{
Debug.Log("Thanks");
}
}
[Serializable]
public class AbstractAnimalChild : AbstractAnimal {}

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

@ -1,4 +0,0 @@
public interface IAnimal
{
void Feed();
}

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

@ -1,7 +0,0 @@
using System;
[Serializable]
public abstract class MammalBase : AnimalBase
{
public int numberOfBones;
}

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

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 05ba0cd389296cf44af17c4e8362fb75
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

@ -1,30 +0,0 @@

public abstract class ApeBase : MammalBase, IApe
{
public string Tag = default;
}
public interface IApe
{
}
public class RedApe : ApeBase
{
}
public class GoldenApe : ApeBase
{
}
public class GreenApe : ApeBase
{
}
public class BlackApe : ApeBase
{
}

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

@ -1,30 +0,0 @@

public abstract class CatBase : MammalBase, ICat
{
public string Tag = default;
}
public interface ICat
{
}
public class RedCat : CatBase
{
}
public class GoldenCat : CatBase
{
}
public class GreenCat : CatBase
{
}
public class BlackCat : CatBase
{
}

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

@ -1,30 +0,0 @@

public abstract class DogBase : MammalBase, IDog
{
public string Tag = default;
}
public interface IDog
{
}
public class RedDog : DogBase
{
}
public class GoldenDog : DogBase
{
}
public class GreenDog : DogBase
{
}
public class BlackDog : DogBase
{
}

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

@ -1,28 +0,0 @@
public abstract class FishBase : AnimalBase, IFish
{
public string Tag = default;
}
public interface IFish
{
}
public class RedFish : FishBase
{
}
public class GoldenFish : FishBase
{
}
public class GreenFish : FishBase
{
}
public class BlackFish : FishBase
{
}

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

@ -1,30 +0,0 @@

public abstract class InsectBase : AnimalBase, IInsect
{
public string Tag = default;
}
public interface IInsect
{
}
public class RedInsect : InsectBase
{
}
public class GoldenInsect : InsectBase
{
}
public class GreenInsect : InsectBase
{
}
public class BlackInsect : InsectBase
{
}

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

@ -1,16 +0,0 @@
{
"name": "SerializedReferenceExample",
"references": [
"GUID:6b7100eb7c609e2418517e5c25caaf2a",
"GUID:73106583b323919458c1e05166706ce3"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

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

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

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

@ -1,62 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!850595691 &4890085278179872738
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: SampleSceneSettings
serializedVersion: 2
m_GIWorkflowMode: 1
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_UsingShadowmask: 1
m_BakeBackend: 0
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_TextureCompression: 1
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 2
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 256
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRRussianRouletteStartBounce: 2
m_PVREnvironmentMIS: 0
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 41149e767ac7dcd47a90a6570ba736eb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

@ -1,236 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
OcclusionCullingSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: 0.25
backfaceThreshold: 100
m_SceneGUID: 00000000000000000000000000000000
m_OcclusionCullingData: {fileID: 0}
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 3
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: 0.5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 11
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 0
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 12
m_Resolution: 2
m_BakeResolution: 40
m_AtlasSize: 1024
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAmbientOcclusion: 0
m_Padding: 2
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_PVRFilteringMode: 2
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVREnvironmentMIS: 0
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_UseShadowmask: 1
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentTypeID: 0
agentRadius: 0.5
agentHeight: 2
agentSlope: 45
agentClimb: 0.4
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
minRegionArea: 2
manualCellSize: 0
cellSize: 0.16666667
manualTileSize: 0
tileSize: 256
accuratePlacement: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &1131539293
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1131539295}
- component: {fileID: 1131539294}
m_Layer: 0
m_Name: Test
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1131539294
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1131539293}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 198888d66cd7476e973e8c52f7f8f04f, type: 3}
m_Name:
m_EditorClassIdentifier:
restrictedAnimals:
id: 0
animalInterface:
id: 1
animalAbstract:
id: 2
animalBaseClass:
id: 3
animalsWithInterfaces:
- id: 4
- id: 5
animalsWithInterfacesMenu: []
classWithChildReferences:
- integerValue: 0
animals:
id: 6
animalInterfaces:
id: 7
references:
version: 1
00000000:
type: {class: GreenApe, ns: , asm: SerializedReferenceExample}
data:
age: 0
food: {fileID: 0}
numberOfBones: 0
Tag:
00000001:
type: {class: RedCat, ns: , asm: SerializedReferenceExample}
data:
age: 0
food: {fileID: 0}
numberOfBones: 0
Tag:
00000002:
type: {class: , ns: , asm: }
00000003:
type: {class: GoldenCat, ns: , asm: SerializedReferenceExample}
data:
age: 0
food: {fileID: 0}
numberOfBones: 0
Tag:
00000004:
type: {class: GoldenCat, ns: , asm: SerializedReferenceExample}
data:
age: 0
food: {fileID: 0}
numberOfBones: 0
Tag:
00000005:
type: {class: RedApe, ns: , asm: SerializedReferenceExample}
data:
age: 0
food: {fileID: 0}
numberOfBones: 0
Tag:
00000006:
type: {class: BlackApe, ns: , asm: SerializedReferenceExample}
data:
age: 0
food: {fileID: 0}
numberOfBones: 0
Tag:
00000007:
type: {class: GreenFish, ns: , asm: SerializedReferenceExample}
data:
age: 0
food: {fileID: 0}
Tag:
--- !u!4 &1131539295
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1131539293}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.4785227, y: 0.00097347796, z: -2.9921875}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 2cda990e2423bbf4892e6590ba056729
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -1,58 +0,0 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
[Header("Restricted to DogBase and IApe")]
[SerializeReference]
[SerializeReferenceButton]
[SerializeReferenceUIRestrictionIncludeTypes(typeof(DogBase), typeof(IApe))]
public IAnimal restrictedAnimals = default;
[Header("Interface")]
[SerializeReference]
[SerializeReferenceButton]
public IAnimal animalInterface = default;
[Header("Abstract")]
[SerializeReference]
[SerializeReferenceButton]
public AbstractAnimal animalAbstract = default;
[Header("Base Class")]
[SerializeReference]
[SerializeReferenceButton]
public AnimalBase animalBaseClass = default;
[Header("List of interfaces")]
[SerializeReference]
[SerializeReferenceButton]
public List<IAnimal> animalsWithInterfaces = new List<IAnimal>();
[Header("List of Animals via MMB menu")]
[SerializeReference]
[SerializeReferenceMenu]
public List<AnimalBase> animalsWithInterfacesMenu = new List<AnimalBase>();
[Header("Class with serialized reference field")]
public List<ClassWithSerializedReferenceChild> classWithChildReferences = default;
}
[Serializable]
public class ClassWithSerializedReferenceChild
{
public int integerValue = default;
[SerializeReference]
[SerializeReferenceButton]
public AnimalBase animals = default;
[SerializeReference]
[SerializeReferenceButton]
public IAnimal animalInterfaces = default;
}

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