Add TypeMenuUtility.GetTypes method
This commit is contained in:
parent
63d2d94953
commit
6269f7f67a
@ -22,7 +22,7 @@ namespace MackySoft.SerializeReferenceExtensions.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int k_MaxTypePopupLineCount = 13;
|
const int k_MaxTypePopupLineCount = 13;
|
||||||
static readonly Type k_UnityObjectType = typeof(UnityEngine.Object);
|
|
||||||
static readonly GUIContent k_NullDisplayName = new GUIContent(TypeMenuUtility.k_NullDisplayName);
|
static readonly GUIContent k_NullDisplayName = new GUIContent(TypeMenuUtility.k_NullDisplayName);
|
||||||
static readonly GUIContent k_IsNotManagedReferenceLabel = new GUIContent("The property type is not manage reference.");
|
static readonly GUIContent k_IsNotManagedReferenceLabel = new GUIContent("The property type is not manage reference.");
|
||||||
|
|
||||||
@ -129,13 +129,7 @@ namespace MackySoft.SerializeReferenceExtensions.Editor
|
|||||||
|
|
||||||
Type baseType = ManagedReferenceUtility.GetType(managedReferenceFieldTypename);
|
Type baseType = ManagedReferenceUtility.GetType(managedReferenceFieldTypename);
|
||||||
var popup = new AdvancedTypePopup(
|
var popup = new AdvancedTypePopup(
|
||||||
TypeCache.GetTypesDerivedFrom(baseType).Append(baseType).Where(p =>
|
TypeMenuUtility.GetTypes(baseType),
|
||||||
(p.IsPublic || p.IsNestedPublic || p.IsNestedPrivate) &&
|
|
||||||
!p.IsAbstract &&
|
|
||||||
!p.IsGenericType &&
|
|
||||||
!k_UnityObjectType.IsAssignableFrom(p) &&
|
|
||||||
Attribute.IsDefined(p,typeof(SerializableAttribute))
|
|
||||||
),
|
|
||||||
k_MaxTypePopupLineCount,
|
k_MaxTypePopupLineCount,
|
||||||
state
|
state
|
||||||
);
|
);
|
||||||
|
|||||||
@ -2,11 +2,25 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
namespace MackySoft.SerializeReferenceExtensions.Editor {
|
namespace MackySoft.SerializeReferenceExtensions.Editor {
|
||||||
public static class TypeMenuUtility {
|
public static class TypeMenuUtility {
|
||||||
|
|
||||||
public const string k_NullDisplayName = "<null>";
|
public const string k_NullDisplayName = "<null>";
|
||||||
|
static readonly Type k_UnityObjectType = typeof(UnityEngine.Object);
|
||||||
|
|
||||||
|
public static IEnumerable<Type> GetTypes (Type baseType)
|
||||||
|
{
|
||||||
|
return TypeCache.GetTypesDerivedFrom(baseType).Append(baseType).Where(p =>
|
||||||
|
(p.IsPublic || p.IsNestedPublic || p.IsNestedPrivate) &&
|
||||||
|
!p.IsAbstract &&
|
||||||
|
!p.IsGenericType &&
|
||||||
|
!k_UnityObjectType.IsAssignableFrom(p) &&
|
||||||
|
Attribute.IsDefined(p, typeof(SerializableAttribute)) &&
|
||||||
|
!Attribute.IsDefined(p, typeof(HideInTypeMenuAttribute))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static AddTypeMenuAttribute GetAttribute (Type type) {
|
public static AddTypeMenuAttribute GetAttribute (Type type) {
|
||||||
return Attribute.GetCustomAttribute(type,typeof(AddTypeMenuAttribute)) as AddTypeMenuAttribute;
|
return Attribute.GetCustomAttribute(type,typeof(AddTypeMenuAttribute)) as AddTypeMenuAttribute;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user