From 354d03d38c15110106a33bdd45940c41842c2ba0 Mon Sep 17 00:00:00 2001 From: uurha Date: Mon, 10 Apr 2023 17:55:13 +0000 Subject: [PATCH] Merge pull request #57 Dev --- .../Drawers/Select/BaseSelectTypeDrawer.cs | 22 ++++--------------- .../Select/SelectImplementationDrawer.cs | 2 +- package.json | 4 ++-- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/Editor/EditorAddons/Drawers/Select/BaseSelectTypeDrawer.cs b/Editor/EditorAddons/Drawers/Select/BaseSelectTypeDrawer.cs index e2299e0..aadb3cb 100644 --- a/Editor/EditorAddons/Drawers/Select/BaseSelectTypeDrawer.cs +++ b/Editor/EditorAddons/Drawers/Select/BaseSelectTypeDrawer.cs @@ -5,6 +5,7 @@ using Better.Attributes.EditorAddons.Drawers.WrapperCollections; using Better.Attributes.Runtime.Select; using Better.EditorTools.Drawers.Base; +using Better.Extensions.Runtime; using UnityEditor; using UnityEngine; using Object = UnityEngine.Object; @@ -23,28 +24,13 @@ protected override WrapperCollection GenerateCollection() return new SelectTypeWrappers(); } - private void LazyGetAllInheritedType(Type baseType, Type currentObjectType) + private void LazyGetAllInheritedType(Type baseType) { if (_reflectionTypes != null) return; - - _reflectionTypes = AppDomain.CurrentDomain.GetAssemblies() - .SelectMany(s => s.GetTypes()).Where(p => ArgIsValueType(baseType, currentObjectType, p)) - .Select(x => (object)x).ToList(); + _reflectionTypes = ReflectionExtensions.GetAllInheritedType(baseType).Cast().ToList(); _reflectionTypes.Insert(0, null); } - private bool ArgIsValueType(Type baseType, Type currentObjectType, Type iterateValue) - { - return iterateValue != currentObjectType && CheckType(baseType, iterateValue) && - (iterateValue.IsClass || iterateValue.IsValueType) && - !iterateValue.IsAbstract && !iterateValue.IsSubclassOf(typeof(Object)); - } - - private bool CheckType(Type baseType, Type p) - { - return baseType.IsAssignableFrom(p); - } - private protected override bool CheckSupported(SerializedProperty property) { return property.propertyType == SerializedPropertyType.ManagedReference; @@ -69,7 +55,7 @@ private protected override void Setup(SerializedProperty property, SelectImplementationAttribute currentAttribute) { var currentObjectType = property.serializedObject.targetObject.GetType(); - LazyGetAllInheritedType(GetFieldOrElementType(), currentObjectType); + LazyGetAllInheritedType(GetFieldOrElementType()); } private protected override GUIContent[] ResolveGroupedName(object value, DisplayGrouping grouping) diff --git a/Editor/EditorAddons/Drawers/Select/SelectImplementationDrawer.cs b/Editor/EditorAddons/Drawers/Select/SelectImplementationDrawer.cs index 21ce4d2..2c305e8 100644 --- a/Editor/EditorAddons/Drawers/Select/SelectImplementationDrawer.cs +++ b/Editor/EditorAddons/Drawers/Select/SelectImplementationDrawer.cs @@ -1,7 +1,7 @@ using System; using System.Reflection; using Better.Attributes.Runtime.Select; -using Better.EditorTools.Comparers; +using Better.EditorTools; using Better.EditorTools.Helpers; using UnityEditor; using UnityEngine; diff --git a/package.json b/package.json index 1b909bd..454b3cc 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "com.uurha.betterattributes", "displayName": "Better Attributes", - "version": "1.6.2", + "version": "1.6.3", "unity": "2018.3", "description": "Unity attributes, allows to serialize interfaces, draw handles for Vector3/Vector2/Quaternion/Bounds, create read only fields.", "dependencies": { - "com.uurha.bettereditortools" : "0.2.0" + "com.uurha.bettereditortools" : "0.3.1" }, "author": { "name": "Arcueid D'athemon",