mirror of
				https://github.com/maxartz15/UnitySerializedReferenceUI.git
				synced 2025-10-31 05:05:45 +01:00 
			
		
		
		
	FIrst Real Commit
Code refactor and migration to github.
This commit is contained in:
		
							
								
								
									
										8
									
								
								Assets/TextusGames.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assets/TextusGames.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 88ad9386d88d6dd4b901fe96a8c2dcc4 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
							
								
								
									
										8
									
								
								Assets/TextusGames/Enhancements.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								Assets/TextusGames/Enhancements.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 45856e53c605df64baf0e89751741df7 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: f549199d6eac96943ae073e003f12aa3 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 1388bc43afa1f4e41ba1032dcee62b04 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,101 @@ | ||||
| #if UNITY_EDITOR | ||||
|  | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using UnityEditor; | ||||
| using UnityEngine; | ||||
|   | ||||
| public static class SerializeReferenceGenericSelectionMenu | ||||
| { | ||||
|     /// Purpose. | ||||
|     /// This is generic selection menu. | ||||
|     /// Filtering.  | ||||
|     /// You can add substring filter here to filter by search string. | ||||
|     /// As well ass type or interface restrictions. | ||||
|     /// As well as any custom restriction that is based on input type. | ||||
|     /// And it will be performed on each Appropriate type found by TypeCache. | ||||
|     public static void ShowContextMenuForManagedReference(this SerializedProperty property, IEnumerable<Func<Type,bool>> filters = null) | ||||
|     {  | ||||
|         var context = new GenericMenu(); | ||||
|         FillContextMenu(filters, context, property); | ||||
|         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; | ||||
|         } | ||||
|           | ||||
|         // 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 | ||||
|     } | ||||
|      | ||||
|     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)); | ||||
|     } | ||||
|      | ||||
|     private static void AssignNewInstanceOfType(object objectGenericMenuParameter ) | ||||
|     { | ||||
|         var parameter = (AssignInstanceGenericMenuParameter) 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)); | ||||
|  | ||||
|      | ||||
|     private readonly struct AssignInstanceGenericMenuParameter | ||||
|     { | ||||
|         public AssignInstanceGenericMenuParameter(Type type, SerializedProperty property) | ||||
|         { | ||||
|             Type = type; | ||||
|             Property = property; | ||||
|         } | ||||
|          | ||||
|         public readonly SerializedProperty Property; | ||||
|         public readonly Type Type; | ||||
|     } | ||||
| }  | ||||
|  | ||||
| #endif | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: d7796948b498be241ba10c88bcf3d5fe | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,23 @@ | ||||
| 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); | ||||
|     }   | ||||
| } | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 07d7d3b6c96d5a04093953c060518522 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 4a5d0da55302d3d418d5afe408a9a916 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 827f3a2847b39a94eb6fcbdb0d73d6ca | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -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 | ||||
| @@ -0,0 +1,31 @@ | ||||
| #if UNITY_EDITOR | ||||
|  | ||||
| using UnityEditor;  | ||||
| using UnityEngine; | ||||
|  | ||||
| [CustomPropertyDrawer(typeof(SerializeReferenceButtonAttribute))] | ||||
| public class SerializeReferenceButtonAttributeDrawer : PropertyDrawer | ||||
| { | ||||
|     public override float GetPropertyHeight(SerializedProperty property, GUIContent label) | ||||
|     { | ||||
|         return EditorGUI.GetPropertyHeight(property, true); | ||||
|     } | ||||
|   | ||||
|     public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | ||||
|     { | ||||
|  | ||||
|          | ||||
|         EditorGUI.BeginProperty(position, label, property);  | ||||
|          | ||||
|         var labelPosition = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); | ||||
|         EditorGUI.LabelField(labelPosition, label);     | ||||
|           | ||||
|         var typeRestrictions = SerializedReferenceUIBuiltInTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo); | ||||
|         property.DrawSelectionButtonForManagedReference(position, typeRestrictions); | ||||
|          | ||||
|         EditorGUI.PropertyField(position, property, GUIContent.none, true); | ||||
|          | ||||
|         EditorGUI.EndProperty();  | ||||
|     }  | ||||
| } | ||||
| #endif | ||||
| @@ -0,0 +1,3 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 5a07638044724309b6088c28a11a15af | ||||
| timeCreated: 1579584059 | ||||
| @@ -0,0 +1,45 @@ | ||||
| #if UNITY_EDITOR | ||||
|  | ||||
| using System; | ||||
| using System.Collections.Generic;  | ||||
| using UnityEditor; | ||||
| using UnityEngine; | ||||
|  | ||||
| public static class SerializeReferenceInspectorButton | ||||
| { | ||||
|     public static readonly Color SerializedReferenceMenuBackgroundColor = new Color(0.1f, 0.55f, 0.9f, 1f); | ||||
|  | ||||
|     /// Must be drawn before DefaultProperty in order to receive input | ||||
|     public static void DrawSelectionButtonForManagedReference(this SerializedProperty property,  Rect position, IEnumerable<Func<Type, bool>> filters = null) =>   | ||||
|         property.DrawSelectionButtonForManagedReference(position, SerializedReferenceMenuBackgroundColor, filters); | ||||
|      | ||||
|     /// Must be drawn before DefaultProperty in order to receive input | ||||
|     public static void DrawSelectionButtonForManagedReference(this SerializedProperty property,  | ||||
|         Rect position, Color color, IEnumerable<Func<Type, bool>> filters = null)   | ||||
|     {  | ||||
|    | ||||
|         var backgroundColor = color;    | ||||
|              | ||||
|         var buttonPosition = position; | ||||
|         buttonPosition.x += EditorGUIUtility.labelWidth + 1 * EditorGUIUtility.standardVerticalSpacing; | ||||
|         buttonPosition.width = position.width - EditorGUIUtility.labelWidth - 1 * EditorGUIUtility.standardVerticalSpacing; | ||||
|         buttonPosition.height = EditorGUIUtility.singleLineHeight; | ||||
|  | ||||
|         var storedIndent = EditorGUI.indentLevel; | ||||
|         EditorGUI.indentLevel = 0; | ||||
|         var storedColor = GUI.backgroundColor; | ||||
|         GUI.backgroundColor = backgroundColor;  | ||||
|           | ||||
|          | ||||
|         var names = SerializeReferenceTypeNameUtility.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 +" )" ))) | ||||
|             property.ShowContextMenuForManagedReference(filters); | ||||
|          | ||||
|         GUI.backgroundColor = storedColor; | ||||
|         EditorGUI.indentLevel = storedIndent; | ||||
|     } | ||||
| } | ||||
|  | ||||
| #endif | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 50b013bc3b4409b438f8781dee4dbbf1 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,21 @@ | ||||
| #if UNITY_EDITOR | ||||
|  | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using UnityEditor; | ||||
| using UnityEngine; | ||||
|  | ||||
| public static class SerializeReferenceInspectorMiddleMouseMenu | ||||
| { | ||||
|     public static void ShowContextMenuForManagedReferenceOnMouseMiddleButton(this SerializedProperty property, | ||||
|         Rect position, IEnumerable<Func<Type, bool>> filters = null) | ||||
|     { | ||||
|         var e = Event.current; | ||||
|         if (e.type != EventType.MouseDown || !position.Contains(e.mousePosition) || e.button != 2)  | ||||
|             return; | ||||
|          | ||||
|         property.ShowContextMenuForManagedReference(filters); | ||||
|     }  | ||||
| } | ||||
|  | ||||
| #endif | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: ba51bcbc90077924abfcf504152b4a51 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: ff8136ca43f822642adfa6388b137133 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -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,26 @@ | ||||
| #if UNITY_EDITOR | ||||
|  | ||||
| using UnityEditor; | ||||
| using UnityEngine; | ||||
|  | ||||
| [CustomPropertyDrawer(typeof(SerializeReferenceMenuAttribute))] | ||||
| public class SerializeReferenceMenuAttributeDrawer : PropertyDrawer | ||||
| { | ||||
|     public override float GetPropertyHeight(SerializedProperty property, GUIContent label) | ||||
|     { | ||||
|         return EditorGUI.GetPropertyHeight(property, true); | ||||
|     } | ||||
|  | ||||
|     public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | ||||
|     { | ||||
|         EditorGUI.BeginProperty(position, label, property); | ||||
|          | ||||
|         var typeRestrictions = SerializedReferenceUIBuiltInTypeRestrictions.GetAllBuiltInTypeRestrictions(fieldInfo); | ||||
|         property.ShowContextMenuForManagedReferenceOnMouseMiddleButton(position, typeRestrictions); | ||||
|          | ||||
|         EditorGUI.PropertyField(position, property, true); | ||||
|         EditorGUI.EndProperty(); | ||||
|     } | ||||
| } | ||||
| #endif | ||||
|  | ||||
| @@ -0,0 +1,3 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: eaa31b1c39ee9424abe12fa0034d9d1b | ||||
| timeCreated: 1579584059 | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: f124bd3bbd4e5e44882fcc7ca4bbfd89 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: c99b932d88d36e9439bb3e944b823502 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,3 @@ | ||||
| { | ||||
| 	"name": "AmimalWorld" | ||||
| } | ||||
| @@ -0,0 +1,7 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 6b7100eb7c609e2418517e5c25caaf2a | ||||
| AssemblyDefinitionImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: b4a0269d5bc8b7345b6e2b1160c596db | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,42 @@ | ||||
| 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 {} | ||||
|  | ||||
|  | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: c24236542320b8b438a9c637fc34365c | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,4 @@ | ||||
| public  interface IAnimal | ||||
| { | ||||
|     void Feed(); | ||||
| } | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 5e7999ba5a7a8e941923ff9d8795fd59 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,7 @@ | ||||
| using System; | ||||
|   | ||||
| [Serializable] | ||||
| public abstract class MammalBase : AnimalBase | ||||
| {   | ||||
|     public int numberOfBones; | ||||
| }   | ||||
| @@ -0,0 +1,3 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: b7dae106e8c3cf94198d8c1d0e9bce89 | ||||
| timeCreated: 1579584059 | ||||
| @@ -0,0 +1,7 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 05ba0cd389296cf44af17c4e8362fb75 | ||||
| TextScriptImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 375e18944bf750b45b54b9715b23432a | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: d16251d523e3f02469f6ce9d3adef548 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,30 @@ | ||||
|  | ||||
| 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 | ||||
| { | ||||
|      | ||||
| } | ||||
|  | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 03b5cf869ca49e343ae00efa8baef1c4 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,30 @@ | ||||
|  | ||||
| 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 | ||||
| { | ||||
|      | ||||
| }  | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 58428c0f2b16db849ad5d61a465d7cbd | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,30 @@ | ||||
|  | ||||
| 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 | ||||
| { | ||||
|      | ||||
| }  | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: a5c4ea427575d4745813d1a491196ed6 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,28 @@ | ||||
| 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 | ||||
| { | ||||
|      | ||||
| } | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: de7faf3ac188d5b4fa97a6f504cb5060 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,30 @@ | ||||
|  | ||||
| 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 | ||||
| { | ||||
|      | ||||
| }  | ||||
| @@ -0,0 +1,11 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 198f13bdfb700f5478f48fa2c8b459c0 | ||||
| MonoImporter: | ||||
|   externalObjects: {} | ||||
|   serializedVersion: 2 | ||||
|   defaultReferences: [] | ||||
|   executionOrder: 0 | ||||
|   icon: {instanceID: 0} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,16 @@ | ||||
| { | ||||
|     "name": "SerializedReferenceExample", | ||||
|     "references": [ | ||||
|         "GUID:6b7100eb7c609e2418517e5c25caaf2a", | ||||
|         "GUID:73106583b323919458c1e05166706ce3" | ||||
|     ], | ||||
|     "includePlatforms": [], | ||||
|     "excludePlatforms": [], | ||||
|     "allowUnsafeCode": false, | ||||
|     "overrideReferences": false, | ||||
|     "precompiledReferences": [], | ||||
|     "autoReferenced": true, | ||||
|     "defineConstraints": [], | ||||
|     "versionDefines": [], | ||||
|     "noEngineReferences": false | ||||
| } | ||||
| @@ -0,0 +1,7 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 9d3c3657da68d4a4e95079ed1fad6bb2 | ||||
| AssemblyDefinitionImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: fe686aa525f35e14498d533b056e962b | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -1,5 +1,5 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: e8e69356eab680c4dbe3066647b5dd77 | ||||
| guid: 32f0237ba42624e46ac3f3ffe9234032 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
| @@ -0,0 +1,62 @@ | ||||
| %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 | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 41149e767ac7dcd47a90a6570ba736eb | ||||
| NativeFormatImporter: | ||||
|   externalObjects: {} | ||||
|   mainObjectFileID: 0 | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -24,9 +24,9 @@ RenderSettings: | ||||
|   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: 0 | ||||
|   m_AmbientMode: 3 | ||||
|   m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} | ||||
|   m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} | ||||
|   m_SkyboxMaterial: {fileID: 0} | ||||
|   m_HaloStrength: 0.5 | ||||
|   m_FlareStrength: 1 | ||||
|   m_FlareFadeSpeed: 3 | ||||
| @@ -37,7 +37,7 @@ RenderSettings: | ||||
|   m_ReflectionBounces: 1 | ||||
|   m_ReflectionIntensity: 1 | ||||
|   m_CustomReflection: {fileID: 0} | ||||
|   m_Sun: {fileID: 705507994} | ||||
|   m_Sun: {fileID: 0} | ||||
|   m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} | ||||
|   m_UseRadianceAmbientProbe: 0 | ||||
| --- !u!157 &3 | ||||
| @@ -51,7 +51,7 @@ LightmapSettings: | ||||
|     m_IndirectOutputScale: 1 | ||||
|     m_AlbedoBoost: 1 | ||||
|     m_EnvironmentLightingMode: 0 | ||||
|     m_EnableBakedLightmaps: 1 | ||||
|     m_EnableBakedLightmaps: 0 | ||||
|     m_EnableRealtimeLightmaps: 0 | ||||
|   m_LightmapEditorSettings: | ||||
|     serializedVersion: 12 | ||||
| @@ -72,7 +72,7 @@ LightmapSettings: | ||||
|     m_FinalGatherRayCount: 256 | ||||
|     m_ReflectionCompression: 2 | ||||
|     m_MixedBakeMode: 2 | ||||
|     m_BakeBackend: 1 | ||||
|     m_BakeBackend: 0 | ||||
|     m_PVRSampling: 1 | ||||
|     m_PVRDirectSampleCount: 32 | ||||
|     m_PVRSampleCount: 500 | ||||
| @@ -121,7 +121,7 @@ NavMeshSettings: | ||||
|     debug: | ||||
|       m_Flags: 0 | ||||
|   m_NavMeshData: {fileID: 0} | ||||
| --- !u!1 &705507993 | ||||
| --- !u!1 &1131539293 | ||||
| GameObject: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
| @@ -129,168 +129,99 @@ GameObject: | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   serializedVersion: 6 | ||||
|   m_Component: | ||||
|   - component: {fileID: 705507995} | ||||
|   - component: {fileID: 705507994} | ||||
|   - component: {fileID: 1131539295} | ||||
|   - component: {fileID: 1131539294} | ||||
|   m_Layer: 0 | ||||
|   m_Name: Directional Light | ||||
|   m_Name: Test | ||||
|   m_TagString: Untagged | ||||
|   m_Icon: {fileID: 0} | ||||
|   m_NavMeshLayer: 0 | ||||
|   m_StaticEditorFlags: 0 | ||||
|   m_IsActive: 1 | ||||
| --- !u!108 &705507994 | ||||
| Light: | ||||
| --- !u!114 &1131539294 | ||||
| MonoBehaviour: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 705507993} | ||||
|   m_GameObject: {fileID: 1131539293} | ||||
|   m_Enabled: 1 | ||||
|   serializedVersion: 10 | ||||
|   m_Type: 1 | ||||
|   m_Shape: 0 | ||||
|   m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} | ||||
|   m_Intensity: 1 | ||||
|   m_Range: 10 | ||||
|   m_SpotAngle: 30 | ||||
|   m_InnerSpotAngle: 21.80208 | ||||
|   m_CookieSize: 10 | ||||
|   m_Shadows: | ||||
|     m_Type: 2 | ||||
|     m_Resolution: -1 | ||||
|     m_CustomResolution: -1 | ||||
|     m_Strength: 1 | ||||
|     m_Bias: 0.05 | ||||
|     m_NormalBias: 0.4 | ||||
|     m_NearPlane: 0.2 | ||||
|     m_CullingMatrixOverride: | ||||
|       e00: 1 | ||||
|       e01: 0 | ||||
|       e02: 0 | ||||
|       e03: 0 | ||||
|       e10: 0 | ||||
|       e11: 1 | ||||
|       e12: 0 | ||||
|       e13: 0 | ||||
|       e20: 0 | ||||
|       e21: 0 | ||||
|       e22: 1 | ||||
|       e23: 0 | ||||
|       e30: 0 | ||||
|       e31: 0 | ||||
|       e32: 0 | ||||
|       e33: 1 | ||||
|     m_UseCullingMatrixOverride: 0 | ||||
|   m_Cookie: {fileID: 0} | ||||
|   m_DrawHalo: 0 | ||||
|   m_Flare: {fileID: 0} | ||||
|   m_RenderMode: 0 | ||||
|   m_CullingMask: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_RenderingLayerMask: 1 | ||||
|   m_Lightmapping: 1 | ||||
|   m_LightShadowCasterMode: 0 | ||||
|   m_AreaSize: {x: 1, y: 1} | ||||
|   m_BounceIntensity: 1 | ||||
|   m_ColorTemperature: 6570 | ||||
|   m_UseColorTemperature: 0 | ||||
|   m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} | ||||
|   m_UseBoundingSphereOverride: 0 | ||||
|   m_ShadowRadius: 0 | ||||
|   m_ShadowAngle: 0 | ||||
| --- !u!4 &705507995 | ||||
|   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: 0 | ||||
|     animalInterfaces: | ||||
|       id: 6 | ||||
|   references: | ||||
|     version: 1 | ||||
|     00000000: | ||||
|       type: {class: BlackApe, 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: 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: 705507993} | ||||
|   m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} | ||||
|   m_LocalPosition: {x: 0, y: 3, z: 0} | ||||
|   m_LocalScale: {x: 1, y: 1, z: 1} | ||||
|   m_Children: [] | ||||
|   m_Father: {fileID: 0} | ||||
|   m_RootOrder: 1 | ||||
|   m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} | ||||
| --- !u!1 &963194225 | ||||
| GameObject: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   serializedVersion: 6 | ||||
|   m_Component: | ||||
|   - component: {fileID: 963194228} | ||||
|   - component: {fileID: 963194227} | ||||
|   - component: {fileID: 963194226} | ||||
|   m_Layer: 0 | ||||
|   m_Name: Main Camera | ||||
|   m_TagString: MainCamera | ||||
|   m_Icon: {fileID: 0} | ||||
|   m_NavMeshLayer: 0 | ||||
|   m_StaticEditorFlags: 0 | ||||
|   m_IsActive: 1 | ||||
| --- !u!81 &963194226 | ||||
| AudioListener: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 963194225} | ||||
|   m_Enabled: 1 | ||||
| --- !u!20 &963194227 | ||||
| Camera: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 963194225} | ||||
|   m_Enabled: 1 | ||||
|   serializedVersion: 2 | ||||
|   m_ClearFlags: 1 | ||||
|   m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} | ||||
|   m_projectionMatrixMode: 1 | ||||
|   m_GateFitMode: 2 | ||||
|   m_FOVAxisMode: 0 | ||||
|   m_SensorSize: {x: 36, y: 24} | ||||
|   m_LensShift: {x: 0, y: 0} | ||||
|   m_FocalLength: 50 | ||||
|   m_NormalizedViewPortRect: | ||||
|     serializedVersion: 2 | ||||
|     x: 0 | ||||
|     y: 0 | ||||
|     width: 1 | ||||
|     height: 1 | ||||
|   near clip plane: 0.3 | ||||
|   far clip plane: 1000 | ||||
|   field of view: 60 | ||||
|   orthographic: 0 | ||||
|   orthographic size: 5 | ||||
|   m_Depth: -1 | ||||
|   m_CullingMask: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_RenderingPath: -1 | ||||
|   m_TargetTexture: {fileID: 0} | ||||
|   m_TargetDisplay: 0 | ||||
|   m_TargetEye: 3 | ||||
|   m_HDR: 1 | ||||
|   m_AllowMSAA: 1 | ||||
|   m_AllowDynamicResolution: 0 | ||||
|   m_ForceIntoRT: 0 | ||||
|   m_OcclusionCulling: 1 | ||||
|   m_StereoConvergence: 10 | ||||
|   m_StereoSeparation: 0.022 | ||||
| --- !u!4 &963194228 | ||||
| Transform: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 963194225} | ||||
|   m_GameObject: {fileID: 1131539293} | ||||
|   m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} | ||||
|   m_LocalPosition: {x: 0, y: 1, z: -10} | ||||
|   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} | ||||
| @@ -1,5 +1,5 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 9fc0d4010bbf28b4594072e72b8655ab | ||||
| guid: 2cda990e2423bbf4892e6590ba056729 | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
| @@ -0,0 +1,58 @@ | ||||
| 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; | ||||
| } | ||||
| @@ -0,0 +1,3 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 198888d66cd7476e973e8c52f7f8f04f | ||||
| timeCreated: 1579584059 | ||||
| @@ -0,0 +1,7 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 97e871ef367e1604391241355b1b3962 | ||||
| TextScriptImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -0,0 +1,8 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: c962b02723999754ba9b137d407b5ec0 | ||||
| folderAsset: yes | ||||
| DefaultImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -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:  | ||||
| @@ -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 SerializedReferenceUIBuiltInTypeRestrictions | ||||
| { | ||||
|     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:  | ||||
| @@ -0,0 +1,3 @@ | ||||
| { | ||||
| 	"name": "Textus.SerializeReferenceUI" | ||||
| } | ||||
| @@ -0,0 +1,7 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: 73106583b323919458c1e05166706ce3 | ||||
| AssemblyDefinitionImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -1,4 +1,4 @@ | ||||
| # UnitySerializedReferenceUI | ||||
| The UI for Unity's SerealizedReference attribute. It allows to change the instance type of field right in editor. | ||||
|  | ||||
| Project is provided under Mit license which you can find in inner main folder | ||||
| Project is provided under Mit license which you can find in inner main folder ("SerializedReferenceUI") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user