2025-09-08 17:37:12 +08:00

57 lines
1.6 KiB
C#

using Mono.Cecil;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using ZXKFramework;
namespace DongWuYiXue.DaoNiaoShu
{
public class SliderPanel : UIBase
{
public override string GroupName => "SliderPanel";
public override string Name => "SliderPanel";
Text text;
Slider slider;
Action<float> okAction;
Action<float> updateAction;
float value;
IUIManager uIManager;
public override void Init(IUIManager uictrl)
{
base.Init(uictrl);
uIManager = uictrl;
text = GetComponentInChildren<Text>();
slider = GetComponentInChildren<Slider>();
slider.onValueChanged.AddListener(Change);
GetComponentInChildren<Button>().onClick.AddListener(OK_Fun);
}
private void OK_Fun()
{
uIManager.CloseUI<ArrowPanel>();
okAction?.Invoke(value);
SetActive(false);
}
private void Change(float f)
{
uIManager.CloseUI<ArrowPanel>();
value = f;
text.text = Convert.ToInt32(f).ToString();
updateAction?.Invoke(f);
}
public void ShowPanel(Vector2 v,float maxValue,float minValue,float initValue, Action<float> update, Action<float> ok)
{
slider.maxValue = maxValue;
slider.minValue = minValue;
slider.value = initValue;
value = initValue;
SetActive(true);
okAction = ok;
updateAction = update;
slider.GetComponent<RectTransform>().anchoredPosition = v;
}
}
}