35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
namespace Ichni.Editor
|
|
{
|
|
public class DynamicUIStringIntPairUnit : DynamicUICompositeUnit
|
|
{
|
|
public TMP_InputField keyInputField, valueInputField;
|
|
|
|
public override void SetUnit(CompositeParameterWindow window, object itemContent)
|
|
{
|
|
var pair = (KeyValuePair<string, int>) itemContent;
|
|
compositeParameterWindow = window;
|
|
|
|
keyInputField.text = pair.Key;
|
|
valueInputField.text = pair.Value.ToString();
|
|
|
|
keyInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
|
valueInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
|
|
|
removeButton.onClick.AddListener(() =>
|
|
{
|
|
compositeParameterWindow.RemoveUnit(this);
|
|
compositeParameterWindow.ApplyParameters();
|
|
});
|
|
}
|
|
|
|
public KeyValuePair<string, int> GetValue()
|
|
{
|
|
return new KeyValuePair<string, int>(keyInputField.text, int.Parse(valueInputField.text));
|
|
}
|
|
}
|
|
} |