Skip to content

Commit

Permalink
Merge pull request #68 from yuyu0127/support-list-view-label-modifica…
Browse files Browse the repository at this point in the history
…tion

Add: Support list view label modification
  • Loading branch information
AnnulusGames committed Mar 21, 2024
2 parents da23ce5 + ae98f77 commit 3ca300f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public string Label
PropertyField propertyField => propertyField.label,
SerializeReferenceField serializeReferenceField => serializeReferenceField.foldout.text,
InlineEditorObjectField inlineEditorObjectField => inlineEditorObjectField.Label,
PropertyListView propertyListView => propertyListView.Label,
_ => null,
};
}
Expand All @@ -101,7 +102,10 @@ public string Label
case InlineEditorObjectField inlineEditorObjectField:
inlineEditorObjectField.Label = value;
break;
};
case PropertyListView propertyListView:
propertyListView.Label = value;
break;
}
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion Alchemy/Assets/Alchemy/Editor/Elements/PropertyListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public PropertyListView(SerializedProperty property)
var parentObj = property.GetDeclaredObject();
var events = property.GetAttribute<OnListViewChangedAttribute>(true);

var listView = GUIHelper.CreateListViewFromFieldInfo(parentObj, property.GetFieldInfo());
listView = GUIHelper.CreateListViewFromFieldInfo(parentObj, property.GetFieldInfo());
listView.headerTitle = ObjectNames.NicifyVariableName(property.displayName);
listView.bindItem = (element, index) =>
{
Expand Down Expand Up @@ -48,5 +48,13 @@ public PropertyListView(SerializedProperty property)
listView.BindProperty(property);
Add(listView);
}

readonly ListView listView;

public string Label
{
get => listView.headerTitle;
set => listView.headerTitle = value;
}
}
}
6 changes: 6 additions & 0 deletions Alchemy/Assets/Alchemy/Samples~/Samples/Samples.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,12 @@ MonoBehaviour:
foo: 0
bar: {x: 0, y: 0, z: 0}
baz: {fileID: 0}
fooList:
- 0
barList:
- {x: 0, y: 0, z: 0}
bazList:
- {fileID: 0}
--- !u!1 &801201066
GameObject:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using UnityEngine;
using Alchemy.Inspector;

Expand All @@ -8,5 +9,9 @@ public class LabelTextSample : MonoBehaviour
[LabelText("FOO!")] public float foo;
[LabelText("BAR!")] public Vector3 bar;
[LabelText("BAZ!")] public GameObject baz;

[LabelText("FOO LIST!")] public List<float> fooList;
[LabelText("BAR LIST!")] public List<Vector3> barList;
[LabelText("BAZ LIST!")] public List<GameObject> bazList;
}
}

0 comments on commit 3ca300f

Please sign in to comment.