Пример #1
0
 public void Deselect()
 {
     if (SelectedChild != null)
     {
         SelectedChild.CurrentState = FlatButtonState.Unselected;
     }
     SelectedChild = null;
 }
Пример #2
0
    // private void OnDisable()
    // {
    //  RemoveListener();
    // }

    public void Clear()
    {
        //RemoveListener();
        foreach (var property in Properties)
        {
            Destroy(property);
        }
        Properties.Clear();
        Buttons.Clear();
        SelectedChild         = null;
        RefreshPropertyValues = null;
        RadioSelection        = false;
    }
Пример #3
0
    public PropertyButton AddProperty(string name, Func <string> read = null, Action <PointerEventData> onClick = null, bool radio = false)
    {
        PropertyButton property;

        if (read != null)
        {
            property = Instantiate(PropertyLabelPrefab, transform);
        }
        else
        {
            property = Instantiate(PropertyPrefab, transform);
        }
        property.Label.text = name;
        if (radio)
        {
            RadioSelection = true;
            Buttons.Add(property.Button);
            property.Button.OnClick += data =>
            {
                if (data.button == PointerEventData.InputButton.Left)
                {
                    if (SelectedChild != null)
                    {
                        SelectedChild.CurrentState = FlatButtonState.Unselected;
                    }
                    SelectedChild = property.Button;
                    SelectedChild.CurrentState = FlatButtonState.Selected;
                }
                onClick?.Invoke(data);
            };
        }
        else if (onClick != null)
        {
            property.Button.OnClick += onClick;
        }

        if (read != null)
        {
            RefreshPropertyValues += () => ((PropertyLabel)property).Value.text = read.Invoke();
        }
        Properties.Add(property.gameObject);
        OnPropertyAdded?.Invoke(property.gameObject);
        return(property);
    }