50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class SettingView : MonoBehaviour
|
|
{
|
|
[Header("Layout ссылки")]
|
|
[SerializeField] private TextMeshProUGUI SettingNameLabel;
|
|
|
|
[Header("Префабы")]
|
|
[SerializeField] private BoolView boolView;
|
|
[SerializeField] private IntView intView;
|
|
[SerializeField] private FloatView floatView;
|
|
[SerializeField] private StringView stringView;
|
|
[SerializeField] private SignalView signalView;
|
|
|
|
ISettingView view;
|
|
|
|
|
|
public void InteractView(int direction)
|
|
{
|
|
if (view == null) return;
|
|
view.TakeInput(direction);
|
|
}
|
|
public void Generate(SettingDTO setting)
|
|
{
|
|
this.name = "(setting) " + setting.Alias;
|
|
SettingNameLabel.text = setting.Alias;
|
|
|
|
var view = Instantiate(ViewByType(setting.Type), transform).GetComponent<ISettingView>();
|
|
view.Initialize(setting);
|
|
this.view = view;
|
|
}
|
|
|
|
private GameObject ViewByType(Setting.SettingType type)
|
|
{
|
|
return type switch
|
|
{
|
|
Setting.SettingType.Bool => boolView.gameObject,
|
|
Setting.SettingType.Float => floatView.gameObject,
|
|
Setting.SettingType.Signal => signalView.gameObject,
|
|
Setting.SettingType.String => stringView.gameObject,
|
|
Setting.SettingType.Int => intView.gameObject,
|
|
_ => boolView.gameObject
|
|
};
|
|
}
|
|
|
|
|
|
|
|
}
|