Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #57
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
uurha committed Apr 10, 2023
1 parent 6797372 commit 354d03d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
22 changes: 4 additions & 18 deletions Editor/EditorAddons/Drawers/Select/BaseSelectTypeDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,28 +24,13 @@ protected override WrapperCollection<SelectTypeWrapper> 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<object>().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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 354d03d

Please sign in to comment.