Skip to content

Commit

Permalink
修复循环嵌套展开bug
Browse files Browse the repository at this point in the history
  • Loading branch information
KumoKyaku committed Feb 12, 2024
1 parent 5b8daa5 commit e7dfe76
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public class SaveTask

/// <summary>
/// 为每个序列化对象的每个path缓存index,同一个path共享index。
/// TODO,这里BUG,当list拖动改变元素顺序时,缓存导致错误。要重新选择才能正确显示。
/// </summary>
public static Dictionary<(UnityEngine.Object Target, string Path), int> SelectedIndex = new();

Expand Down Expand Up @@ -606,7 +607,9 @@ public float GetUnityObjectFieldPropertyHeight(SerializedProperty property, GUIC
{
var canExpand = (attribute as NewButtonAttribute)?.CanExpand ?? true;

if (canExpand && property.isExpanded && property.objectReferenceValue != null)
if (canExpand && property.isExpanded
&& property.objectReferenceValue != null
&& property.objectReferenceValue != property.serializedObject.targetObject)//防止循环嵌套展开
{
using (SerializedObject serializedObject = new SerializedObject(property.objectReferenceValue))
{
Expand Down Expand Up @@ -652,7 +655,8 @@ public void DrawUnityObjectField(SerializedProperty property,
{
var canExpand = (attribute as NewButtonAttribute)?.CanExpand ?? true;
if (canExpand && property.propertyType == SerializedPropertyType.ObjectReference
&& property.objectReferenceValue != null)
&& property.objectReferenceValue != null
&& property.objectReferenceValue != property.serializedObject.targetObject)//防止循环嵌套展开
{
// Draw a foldout
Rect foldoutRect = new Rect()
Expand Down

0 comments on commit e7dfe76

Please sign in to comment.