Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 69943b46c8 | |||
| 66fc5ae911 | |||
| 1757747985 |
+1
-18
@@ -5,8 +5,6 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.IMGUI.Controls;
|
using UnityEditor.IMGUI.Controls;
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using UnityEditor.UIElements;
|
|
||||||
|
|
||||||
namespace MackySoft.SerializeReferenceExtensions.Editor
|
namespace MackySoft.SerializeReferenceExtensions.Editor
|
||||||
{
|
{
|
||||||
@@ -112,21 +110,6 @@ namespace MackySoft.SerializeReferenceExtensions.Editor
|
|||||||
EditorGUI.EndProperty();
|
EditorGUI.EndProperty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override VisualElement CreatePropertyGUI (SerializedProperty property)
|
|
||||||
{
|
|
||||||
VisualElement root = new VisualElement();
|
|
||||||
if (property.propertyType == SerializedPropertyType.ManagedReference)
|
|
||||||
{
|
|
||||||
TypePopupField typePopupField = new TypePopupField(property, new VisualElement());
|
|
||||||
root.Add(typePopupField);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new Label(k_IsNotManagedReferenceLabel.text);
|
|
||||||
}
|
|
||||||
return root;
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyDrawer GetCustomPropertyDrawer (SerializedProperty property)
|
PropertyDrawer GetCustomPropertyDrawer (SerializedProperty property)
|
||||||
{
|
{
|
||||||
Type propertyType = ManagedReferenceUtility.GetType(property.managedReferenceFullTypename);
|
Type propertyType = ManagedReferenceUtility.GetType(property.managedReferenceFullTypename);
|
||||||
@@ -147,7 +130,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 =>
|
TypeCache.GetTypesDerivedFrom(baseType).Append(baseType).Where(p =>
|
||||||
(p.IsPublic || p.IsNestedPublic) &&
|
(p.IsPublic || p.IsNestedPublic || p.IsNestedPrivate) &&
|
||||||
!p.IsAbstract &&
|
!p.IsAbstract &&
|
||||||
!p.IsGenericType &&
|
!p.IsGenericType &&
|
||||||
!k_UnityObjectType.IsAssignableFrom(p) &&
|
!k_UnityObjectType.IsAssignableFrom(p) &&
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
#if UNITY_2019_3_OR_NEWER
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace MackySoft.SerializeReferenceExtensions.Editor
|
|
||||||
{
|
|
||||||
public sealed class TypePopupField : BaseField<object>
|
|
||||||
{
|
|
||||||
|
|
||||||
public new static readonly string ussClassName = "unity-base-popup-field";
|
|
||||||
|
|
||||||
public static readonly string textUssClassName = ussClassName + "__text";
|
|
||||||
|
|
||||||
public static readonly string arrowUssClassName = ussClassName + "__arrow";
|
|
||||||
|
|
||||||
public new static readonly string labelUssClassName = ussClassName + "__label";
|
|
||||||
|
|
||||||
public new static readonly string inputUssClassName = ussClassName + "__input";
|
|
||||||
|
|
||||||
readonly SerializedProperty m_Property;
|
|
||||||
|
|
||||||
readonly Toggle m_Toggle;
|
|
||||||
|
|
||||||
readonly VisualElement m_ArrowElement;
|
|
||||||
readonly Label m_TextElement;
|
|
||||||
|
|
||||||
public TypePopupField (SerializedProperty property, VisualElement visualInput) : base(property.displayName, visualInput)
|
|
||||||
{
|
|
||||||
m_Property = property;
|
|
||||||
|
|
||||||
style.flexDirection = FlexDirection.Row;
|
|
||||||
style.flexShrink = 0;
|
|
||||||
style.flexGrow = 1;
|
|
||||||
|
|
||||||
AddToClassList(ussClassName);
|
|
||||||
AddToClassList("unity-base-field__aligned");
|
|
||||||
AddToClassList("unity-base-field__inspector-field");
|
|
||||||
|
|
||||||
labelElement.AddToClassList(labelUssClassName);
|
|
||||||
labelElement.AddToClassList("unity-popup-field__label");
|
|
||||||
labelElement.AddToClassList("unity-property-field__label");
|
|
||||||
|
|
||||||
m_TextElement = new Label(property.displayName)
|
|
||||||
{
|
|
||||||
pickingMode = PickingMode.Ignore
|
|
||||||
};
|
|
||||||
m_TextElement.AddToClassList(textUssClassName);
|
|
||||||
visualInput.AddToClassList(inputUssClassName);
|
|
||||||
visualInput.Add(m_TextElement);
|
|
||||||
visualInput.pickingMode = PickingMode.Ignore;
|
|
||||||
|
|
||||||
m_ArrowElement = new VisualElement();
|
|
||||||
m_ArrowElement.AddToClassList(arrowUssClassName);
|
|
||||||
m_ArrowElement.pickingMode = PickingMode.Ignore;
|
|
||||||
visualInput.Add(m_ArrowElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ad665a39f1251a14ea9f40c0c9cf3a75
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "com.mackysoft.serializereference-extensions",
|
"name": "com.mackysoft.serializereference-extensions",
|
||||||
"displayName": "SerializeReference Extensions",
|
"displayName": "SerializeReference Extensions",
|
||||||
"author": { "name": "MackySoft", "url": "https://github.com/mackysoft" },
|
"author": { "name": "MackySoft", "url": "https://github.com/mackysoft" },
|
||||||
"version": "1.3.1",
|
"version": "1.4.0",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
"description": "Provide popup to specify the type of the field serialized by the [SerializeReference] attribute in the inspector.",
|
"description": "Provide popup to specify the type of the field serialized by the [SerializeReference] attribute in the inspector.",
|
||||||
"keywords": [ "SerializeReference", "Editor" ],
|
"keywords": [ "SerializeReference", "Editor" ],
|
||||||
|
|||||||
Reference in New Issue
Block a user