Skip to content

Conversation

@yuyu0127
Copy link
Contributor

@yuyu0127 yuyu0127 commented Mar 16, 2024

I added ElementLabelTextSelector property to ListViewSettings attribute, allowing for the editing of labels for each element in the list.
ElementLabelTextSelector property is the name of a method, which takes an int type element index as the argument and returns a string type label.

This works as follows:

image

using System.Collections.Generic;
using UnityEngine;
using Alchemy.Inspector;

namespace Alchemy.Samples
{
    public class LabelTextSample : MonoBehaviour
    {
        [LabelText("FOO LIST!"), ListViewSettings(ElementLabelTextSelector = nameof(GetFooLabel))]
        public List<float> fooList;
        [LabelText("BAR LIST!"), ListViewSettings(ElementLabelTextSelector = nameof(GetBarLabel))]
        public List<Vector3> barList;
        [LabelText("BAZ LIST!"), ListViewSettings(ElementLabelTextSelector = nameof(GetBazLabel))]
        public List<GameObject> bazList;

        private string GetFooLabel(int index) => $"FOO [{index}] {fooList[index]}";
        private string GetBarLabel(int index) => $"BAR [{index}] {barList[index]}";
        private string GetBazLabel(int index) => $"BAZ [{index}] {bazList[index]}";
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant