Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.0.3 #11

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using Better.Commons.Runtime.Comparers;

namespace Better.Attributes.EditorAddons.Comparers
{
public class SelectImplementationTypeComparer : BaseComparer<SelectImplementationTypeComparer, Type>, IEqualityComparer<Type>
{
public bool Equals(Type x, Type y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.IsAssignableFrom(y) || x == y) return true;
if ((y.IsInterface || y.IsAbstract) && x == typeof(Type)) return true;
return x == typeof(Type);
}

public int GetHashCode(Type obj)
{
return 0;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override BaseHandlersTypeCollection GenerateCollection()
return new HandlersTypeCollection(TypeComparer.Instance)
{
{
typeof(SelectAttribute), new Dictionary<Type, Type>(TypeComparer.Instance)
typeof(SelectAttribute), new Dictionary<Type, Type>(SelectImplementationTypeComparer.Instance)
{
{ typeof(SerializedType), typeof(SelectSerializedTypeHandler) },
{ typeof(Enum), typeof(SelectEnumHandler) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override bool IsSkippingFieldDraw()
public override bool CheckSupported()
{
var baseType = GetFieldOrElementType();
return baseType.IsAbstract || baseType.IsInterface;
return baseType.IsAbstract || baseType.IsInterface || baseType.HasParameterlessConstructor();
}

public override bool ValidateSelected(object item)
Expand Down
2 changes: 1 addition & 1 deletion Assets/BetterAttributes/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "com.tdw.better.attributes",
"displayName": "Better Attributes",
"version": "0.0.2",
"version": "0.0.3",
"unity": "2021.3",
"description": "Unity attributes, allows to serialize interfaces, draw handles for Vector3/Vector2/Quaternion/Bounds, create read only fields.",
"dependencies": {
Expand Down
3 changes: 1 addition & 2 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
"name": "Better Plugins",
"url": "https://package.openupm.com",
"scopes": [
"com.tdw",
"com.uurha"
"com.tdw"
]
}
]
Expand Down
11 changes: 5 additions & 6 deletions ProjectSettings/PackageManagerSettings.asset

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading