Skip to content

Commit

Permalink
增加能否展开设定
Browse files Browse the repository at this point in the history
  • Loading branch information
KumoKyaku committed Jan 5, 2024
1 parent ab58748 commit e13941d
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public class NewButtonAttribute : PropertyAttribute
public int LeftButtonWidth { get; set; } = 40;
public int RightButtonWidth { get; set; } = 40;

/// <summary>
/// 是否在当前Inspector展开子嵌套对象
/// </summary>
public bool CanExpand { get; set; } = true;

public NewButtonAttribute()
{

Expand Down Expand Up @@ -387,7 +392,7 @@ public void ClickTypeLable(Type targetType)
}
}

private static void NewCloneCurrentUnityObject(SerializedProperty property, GUIContent label, Rect position, Rect propertyPosition, Rect leftPosotion, Rect rightPosition, UnityEngine.Object obj)
public void NewCloneCurrentUnityObject(SerializedProperty property, GUIContent label, Rect position, Rect propertyPosition, Rect leftPosotion, Rect rightPosition, UnityEngine.Object obj)
{
Type targetType = obj.GetType();
//EditorGUI.PropertyField(propertyPosition, property, label);
Expand Down Expand Up @@ -556,9 +561,11 @@ public void CacheSupportType(SerializedProperty property)
//从 https://github.com/dbrizov/NaughtyAttributes 修改
partial class INewCloneButtonDrawer_72946648EEF14A43B837BAC45D14BFF3
{
public static float GetUnityObjectFieldPropertyHeight(SerializedProperty property, GUIContent label)
public float GetUnityObjectFieldPropertyHeight(SerializedProperty property, GUIContent label)
{
if (property.isExpanded && property.objectReferenceValue != null)
var canExpand = (attribute as NewButtonAttribute)?.CanExpand ?? true;

if (canExpand && property.isExpanded && property.objectReferenceValue != null)
{
using (SerializedObject serializedObject = new SerializedObject(property.objectReferenceValue))
{
Expand Down Expand Up @@ -596,13 +603,14 @@ public static float GetUnityObjectFieldPropertyHeight(SerializedProperty propert
return EditorGUI.GetPropertyHeight(property, label);
}

public static void DrawUnityObjectField(SerializedProperty property,
public void DrawUnityObjectField(SerializedProperty property,
GUIContent label,
Rect position,
Rect propertyPosition,
Type targetType)
{
if (property.propertyType == SerializedPropertyType.ObjectReference
var canExpand = (attribute as NewButtonAttribute)?.CanExpand ?? true;
if (canExpand && property.propertyType == SerializedPropertyType.ObjectReference
&& property.objectReferenceValue != null)
{
// Draw a foldout
Expand Down

0 comments on commit e13941d

Please sign in to comment.