106 lines
2.6 KiB
C#

using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using Assets.Scripts.UI.Control;
using System;
using UnityEngine.EventSystems;
using UnityEngine.Events;
public class Confirm3 : PFUIPanel
{
private PFUIText _title;
private PFUIText _content;
private PfUIButton _1;
private PfUIButton _2;
private PfUIButton _3;
private UnityAction _action1;
private UnityAction _action2;
private UnityAction _action3;
protected override void Awake()
{
var wrap = this.transform.Find("GameObject");
_title = wrap.Find("Title").GetComponent<PFUIText>();
_content = wrap.Find("Content").GetComponent<PFUIText>();
_1 = wrap.Find("Container/Save").GetComponent<PfUIButton>();
_2 = wrap.Find("Container/Discard").GetComponent<PfUIButton>();
_3 = wrap.Find("Container/Cancel").GetComponent<PfUIButton>();
UIManager.AddEvent(_1.gameObject, EventTriggerType.PointerClick, (e) =>
{
if(_action1 != null)
{
_action1();
}
});
UIManager.AddEvent(_2.gameObject, EventTriggerType.PointerClick, (e) =>
{
if (_action2 != null)
{
_action2();
}
this.Close();
});
UIManager.AddEvent(_3.gameObject, EventTriggerType.PointerClick, (e) =>
{
if (_action3 != null)
{
_action3();
}
this.Close();
});
}
// Start is called before the first frame update
protected override void Start()
{
}
public void Set(string title, string content, UnityAction action1,UnityAction action2, UnityAction action3)
{
//if(text == null)
//{
// return;
//}
//text.text = txt;
_title.Text = title;
_content.Text = content;
_action1 = action1;
_action2 = action2;
_action3 = action3;
}
// Update is called once per frame
void Update()
{
}
public override void Show()
{
var panel = this.transform.Find("Panel");
var bg = panel.GetComponent<Image>();
//bg.alphaHitTestMinimumThreshold
var color = bg.color;
color.a = 0.6f;
bg.color = color;
base.Show();
}
public override void Close()
{
var panel = this.transform.Find("Panel");
var bg = panel.GetComponent<Image>();
bg.DOFade(0, 0.2f).OnComplete(() =>
{
this.gameObject.SetActive(false);
});
}
}