From 7bcba82fb18bd672eb61f5bcf7ff4c27c11b2917 Mon Sep 17 00:00:00 2001 From: uurha Date: Thu, 25 Jul 2024 13:45:23 +0000 Subject: [PATCH] Merge pull request #126 from techno-dwarf-works/feature/refactoring Version 3.1.6 --- .../Handlers/SelectSerializedTypeHandler.cs | 9 ++++++++- .../EditorAddons/Drawers/Select/SelectDrawer.cs | 1 - .../Scripts/Models/SomeAbstractClass.cs | 3 --- .../Models/SomeAbstractClassImplementation2.cs | 9 +++++++++ Samples~/TestSamples/Scripts/Test.cs | 16 ++++++++++++++++ package.json | 4 ++-- 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Editor/EditorAddons/Drawers/Select/Handlers/SelectSerializedTypeHandler.cs b/Editor/EditorAddons/Drawers/Select/Handlers/SelectSerializedTypeHandler.cs index b2c3ebd..2172782 100644 --- a/Editor/EditorAddons/Drawers/Select/Handlers/SelectSerializedTypeHandler.cs +++ b/Editor/EditorAddons/Drawers/Select/Handlers/SelectSerializedTypeHandler.cs @@ -43,7 +43,14 @@ public override object GetCurrentValue() { var property = _container.SerializedProperty; var objectOfProperty = property.GetValue(); - var type = objectOfProperty.GetType(); + Type type = null; + if (objectOfProperty == null) + { + type = GetFieldOrElementType(); + return type; + } + + type = objectOfProperty.GetType(); if (type == typeof(SerializedType)) { type = (objectOfProperty as SerializedType)?.Type; diff --git a/Editor/EditorAddons/Drawers/Select/SelectDrawer.cs b/Editor/EditorAddons/Drawers/Select/SelectDrawer.cs index 2f8c957..15956f0 100644 --- a/Editor/EditorAddons/Drawers/Select/SelectDrawer.cs +++ b/Editor/EditorAddons/Drawers/Select/SelectDrawer.cs @@ -21,7 +21,6 @@ public class SelectDrawer : BasePropertyDrawer> _behavioredElements; - private Guid g = Guid.NewGuid(); public SelectDrawer() { diff --git a/Samples~/TestSamples/Scripts/Models/SomeAbstractClass.cs b/Samples~/TestSamples/Scripts/Models/SomeAbstractClass.cs index 3b32b41..b994ee3 100644 --- a/Samples~/TestSamples/Scripts/Models/SomeAbstractClass.cs +++ b/Samples~/TestSamples/Scripts/Models/SomeAbstractClass.cs @@ -6,8 +6,5 @@ namespace Samples.Models [Serializable] public abstract class SomeAbstractClass { - [SerializeField] private protected int baseIntField; - - public int BaseIntField => baseIntField; } } \ No newline at end of file diff --git a/Samples~/TestSamples/Scripts/Models/SomeAbstractClassImplementation2.cs b/Samples~/TestSamples/Scripts/Models/SomeAbstractClassImplementation2.cs index 04023bf..9470ea4 100644 --- a/Samples~/TestSamples/Scripts/Models/SomeAbstractClassImplementation2.cs +++ b/Samples~/TestSamples/Scripts/Models/SomeAbstractClassImplementation2.cs @@ -7,5 +7,14 @@ namespace Samples.Models public class SomeAbstractClassImplementation2 : SomeAbstractClass { [SerializeField] private bool boolField; + + [SerializeField] private protected int baseIntField; + + public int BaseIntField => baseIntField; + } + + [Serializable] + public class SomeAbstractClassImplementation3 : SomeAbstractClass + { } } \ No newline at end of file diff --git a/Samples~/TestSamples/Scripts/Test.cs b/Samples~/TestSamples/Scripts/Test.cs index 4295a10..b5fe35c 100644 --- a/Samples~/TestSamples/Scripts/Test.cs +++ b/Samples~/TestSamples/Scripts/Test.cs @@ -61,12 +61,28 @@ public class TestInner private int testIntLog; } + [Serializable] + public class TestSerializableType : ITestSerializableType + { + [Select(typeof(ISomeInterface))] + [SerializeField] + private List serializedTypes; + } + + public interface ITestSerializableType + { + } + public class Test : MonoBehaviour { [HideLabel] [Select(typeof(ISomeInterface))] [SerializeField] private SerializedType serializedType; + [Select] + [SerializeReference] + private List serializedTypes; + [Select(typeof(ISomeInterface))] [SerializeField] private SerializedType serializedType2; diff --git a/package.json b/package.json index 4ee7b05..32976c6 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "com.uurha.betterattributes", "displayName": "Better Attributes", - "version": "3.1.5", + "version": "3.1.6", "unity": "2021.3", "description": "Unity attributes, allows to serialize interfaces, draw handles for Vector3/Vector2/Quaternion/Bounds, create read only fields.", "dependencies": { - "com.tdw.better.commons" : "0.0.16", + "com.tdw.better.commons" : "0.0.26", "com.tdw.better.internal.core" : "0.0.2" }, "author": {