Merge pull request #68 from yuyu0127/support-list-view-label-modification

Add: Support list view label modification
This commit is contained in:
Annulus Games 2024-03-21 10:50:53 +09:00 committed by GitHub
commit 3ca300ff34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 2 deletions

View File

@ -82,6 +82,7 @@ namespace Alchemy.Editor.Elements
PropertyField propertyField => propertyField.label, PropertyField propertyField => propertyField.label,
SerializeReferenceField serializeReferenceField => serializeReferenceField.foldout.text, SerializeReferenceField serializeReferenceField => serializeReferenceField.foldout.text,
InlineEditorObjectField inlineEditorObjectField => inlineEditorObjectField.Label, InlineEditorObjectField inlineEditorObjectField => inlineEditorObjectField.Label,
PropertyListView propertyListView => propertyListView.Label,
_ => null, _ => null,
}; };
} }
@ -101,7 +102,10 @@ namespace Alchemy.Editor.Elements
case InlineEditorObjectField inlineEditorObjectField: case InlineEditorObjectField inlineEditorObjectField:
inlineEditorObjectField.Label = value; inlineEditorObjectField.Label = value;
break; break;
}; case PropertyListView propertyListView:
propertyListView.Label = value;
break;
}
} }
} }
} }

View File

@ -19,7 +19,7 @@ namespace Alchemy.Editor.Elements
var parentObj = property.GetDeclaredObject(); var parentObj = property.GetDeclaredObject();
var events = property.GetAttribute<OnListViewChangedAttribute>(true); 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.headerTitle = ObjectNames.NicifyVariableName(property.displayName);
listView.bindItem = (element, index) => listView.bindItem = (element, index) =>
{ {
@ -48,5 +48,13 @@ namespace Alchemy.Editor.Elements
listView.BindProperty(property); listView.BindProperty(property);
Add(listView); Add(listView);
} }
readonly ListView listView;
public string Label
{
get => listView.headerTitle;
set => listView.headerTitle = value;
}
} }
} }

View File

@ -1085,6 +1085,12 @@ MonoBehaviour:
foo: 0 foo: 0
bar: {x: 0, y: 0, z: 0} bar: {x: 0, y: 0, z: 0}
baz: {fileID: 0} baz: {fileID: 0}
fooList:
- 0
barList:
- {x: 0, y: 0, z: 0}
bazList:
- {fileID: 0}
--- !u!1 &801201066 --- !u!1 &801201066
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -1,3 +1,4 @@
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using Alchemy.Inspector; using Alchemy.Inspector;
@ -8,5 +9,9 @@ namespace Alchemy.Samples
[LabelText("FOO!")] public float foo; [LabelText("FOO!")] public float foo;
[LabelText("BAR!")] public Vector3 bar; [LabelText("BAR!")] public Vector3 bar;
[LabelText("BAZ!")] public GameObject baz; [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;
} }
} }