123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- 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 Text NotifyLab;
- public static Image Icon;
- public static Button Cancel;
- public static Button Confirm;
- public static Transform Box;
- public static Transform Background;
- #endregion
- public override bool InitAtOnce()
- {
- if (base.InitAtOnce())
- {
- return true;
- }
- Box = ResourceManager.Get(CanvasLabel.K_Bubble0);
- Background = ResourceManager.Get(CanvasLabel.K_Bubble);
- Tit = ResourceManager.Get<Text>(CanvasLabel.K_Tit);
- Lab = ResourceManager.Get<Text>(CanvasLabel.K_Lab);
- NotifyLab = ResourceManager.Get<Text>(CanvasLabel.K_NotifyLab);
- Icon = ResourceManager.Get<Image>(CanvasLabel.K_Icon);
- Cancel = ResourceManager.Get<Button>(CanvasLabel.K_Cancel);
- Confirm = ResourceManager.Get<Button>(CanvasLabel.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, string notifyLab = null, Sprite sprite = null, UnityAction confirmAction = null, UnityAction cancelAction = null, bool enableCancle = true)
- {
- AudioManager.PlayClip(AudioLabel.Bubble);
- 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 (string.IsNullOrEmpty(notifyLab))
- {
- NotifyLab.SetActive(false);
- }
- else
- {
- NotifyLab.SetActive(true);
- NotifyLab.text = notifyLab;
- }
- 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
- (
- () =>
- {
- AudioManager.PlayClip(AudioLabel.ClickButton);
- }
- );
- if (cancelAction != null)
- {
- Cancel.AddButtonEvent(cancelAction);
- }
- else
- {
- if (!enableCancle)
- {
- Cancel.SetActive(false);
- }
- }
- Confirm.SetButtonEvent(Close);
- Confirm.AddButtonEvent(confirmAction);
- Confirm.AddButtonEvent
- (
- () =>
- {
- AudioManager.PlayClip(AudioLabel.ClickButton);
- }
- );
- }
- }
- public static void Close()
- {
- Box.TweenBacScale();
- Background.TweenBacGra();
- AudioManager.PlayClip(AudioLabel.Close);
- }
- }
|