Fix use prefixLabel position right away
This commit is contained in:
parent
a8bcece352
commit
c9b5193e51
@ -35,19 +35,14 @@ namespace MackySoft.SerializeReferenceExtensions.Editor
|
|||||||
EditorGUI.BeginProperty(position,label,property);
|
EditorGUI.BeginProperty(position,label,property);
|
||||||
|
|
||||||
if (property.propertyType == SerializedPropertyType.ManagedReference) {
|
if (property.propertyType == SerializedPropertyType.ManagedReference) {
|
||||||
|
|
||||||
// render label first to avoid label overlap for lists
|
// render label first to avoid label overlap for lists
|
||||||
Rect foldoutLabelRect = new Rect(position);
|
Rect foldoutLabelRect = new Rect(position);
|
||||||
foldoutLabelRect.height = EditorGUIUtility.singleLineHeight;
|
foldoutLabelRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
foldoutLabelRect.x += EditorGUI.indentLevel * 12;
|
foldoutLabelRect.x += EditorGUI.indentLevel * 12;
|
||||||
EditorGUI.PrefixLabel(foldoutLabelRect, label);
|
Rect popupPosition = EditorGUI.PrefixLabel(foldoutLabelRect, label);
|
||||||
|
|
||||||
// Draw the subclass selector popup.
|
|
||||||
Rect popupPosition = new Rect(position);
|
|
||||||
popupPosition.width -= EditorGUIUtility.labelWidth;
|
|
||||||
popupPosition.x += EditorGUIUtility.labelWidth;
|
|
||||||
popupPosition.height = EditorGUIUtility.singleLineHeight;
|
|
||||||
|
|
||||||
|
// Draw the subclass selector popup.
|
||||||
if (EditorGUI.DropdownButton(popupPosition,GetTypeName(property),FocusType.Keyboard)) {
|
if (EditorGUI.DropdownButton(popupPosition,GetTypeName(property),FocusType.Keyboard)) {
|
||||||
TypePopupCache popup = GetTypePopup(property);
|
TypePopupCache popup = GetTypePopup(property);
|
||||||
m_TargetProperty = property;
|
m_TargetProperty = property;
|
||||||
@ -62,7 +57,7 @@ namespace MackySoft.SerializeReferenceExtensions.Editor
|
|||||||
Rect foldoutRect = new Rect(position);
|
Rect foldoutRect = new Rect(position);
|
||||||
foldoutRect.height = EditorGUIUtility.singleLineHeight;
|
foldoutRect.height = EditorGUIUtility.singleLineHeight;
|
||||||
property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, GUIContent.none, true);
|
property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, GUIContent.none, true);
|
||||||
|
|
||||||
if (property.isExpanded)
|
if (property.isExpanded)
|
||||||
{
|
{
|
||||||
using (new EditorGUI.IndentLevelScope())
|
using (new EditorGUI.IndentLevelScope())
|
||||||
@ -102,7 +97,7 @@ namespace MackySoft.SerializeReferenceExtensions.Editor
|
|||||||
|
|
||||||
if (!m_TypePopups.TryGetValue(managedReferenceFieldTypename,out TypePopupCache result)) {
|
if (!m_TypePopups.TryGetValue(managedReferenceFieldTypename,out TypePopupCache result)) {
|
||||||
var state = new AdvancedDropdownState();
|
var state = new AdvancedDropdownState();
|
||||||
|
|
||||||
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 =>
|
||||||
@ -125,7 +120,7 @@ namespace MackySoft.SerializeReferenceExtensions.Editor
|
|||||||
|
|
||||||
object obj = individualProperty.SetManagedReference(type);
|
object obj = individualProperty.SetManagedReference(type);
|
||||||
individualProperty.isExpanded = (obj != null);
|
individualProperty.isExpanded = (obj != null);
|
||||||
|
|
||||||
individualObject.ApplyModifiedProperties();
|
individualObject.ApplyModifiedProperties();
|
||||||
individualObject.Update();
|
individualObject.Update();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user