123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.Events;
- using System.Collections;
- public class Bubble : Regist
- {
- #region 变量
- public static Text Tit;
- public static Text Lab;
- public static Image Icon;
- public static Button Cancel;
- public static Button Confirm;
- public static Transform Box;
- public static Transform Background;
- #endregion
- public override bool RegistImmed()
- {
- if (base.RegistImmed())
- {
- return true;
- }
- Box = ManaReso.Get("K_Bubble0");
- Background = ManaReso.Get("K_Bubble");
- Tit = ManaReso.Get<Text>("K_Tit");
- Lab = ManaReso.Get<Text>("K_Lab");
- Icon = ManaReso.Get<Image>("K_Icon");
- Cancel = ManaReso.Get<Button>("K_Cancel");
- Confirm = ManaReso.Get<Button>("K_Confirm");
- Box.CreateTweenScale(Vector3.zero, Vector3.one, 0.25f, false, true, Curve.EaseOutQuad);
- Background.CreateTweenGra(0, 180 / 255f, 0.25f, false, true, Curve.EaseOutQuad, true);
- return false;
- }
- public static void Show(string tit = null, string lab = null, Sprite sprite = null, UnityAction confirmAction = null, UnityAction cancelAction = null)
- {
- ManaAudio.PlayClip(Clip.BubbleClip);
- Box.TweenForScale();
- Background.TweenForGra();
- if (string.IsNullOrEmpty(tit))
- {
- Tit.SetActive(false);
- }
- else
- {
- Tit.SetActive(true);
- Tit.text = tit;
- }
- if (string.IsNullOrEmpty(lab))
- {
- Lab.SetActive(false);
- }
- else
- {
- Lab.SetActive(true);
- Lab.text = lab;
- }
- if (sprite == null)
- {
- Icon.SetActive(false);
- }
- else
- {
- Icon.SetActive(true);
- Icon.sprite = sprite;
- }
- if (cancelAction == null && confirmAction == null)
- {
- Cancel.SetActive(false);
- Confirm.SetButtonEvent(Close);
- }
- else
- {
- Cancel.SetActive(true);
- Cancel.SetButtonEvent(Close);
- Cancel.AddButtonEvent
- (
- () =>
- {
- ManaAudio.PlayClip(Clip.BtnClip);
- }
- );
- if (cancelAction != null)
- {
- Cancel.AddButtonEvent(cancelAction);
- }
- Confirm.SetButtonEvent(Close);
- Confirm.AddButtonEvent(confirmAction);
- Confirm.AddButtonEvent
- (
- () =>
- {
- ManaAudio.PlayClip(Clip.BtnClip);
- }
- );
- }
- }
- public static void Close()
- {
- Box.TweenBacScale();
- Background.TweenBacGra();
- ManaAudio.PlayClip(Clip.CloseClip);
- }
- }
|