// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2020-09-19 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using System.Collections; using TMPro; using UnityEngine; using UnityEngine.UI; namespace G.UI { partial class ToastBox { /// /// /// private class ToastWidget : KUIWidget { #region Field #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] TextMeshProUGUI _tmpContent; [KUIFlag] TextMeshProUGUI _tmpContent2; [KUIFlag] KUIImage _imgFrame; [KUIFlag] Image _imgIcon; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null CanvasGroup _canvasGroup; #endregion #region Method /// /// /// /// public void SetText(string text) { if (_tmpContent) _tmpContent.text = text; } public void SetText2(string text) { if (_tmpContent2) _tmpContent2.text = text; } public void SetNumber(int number1, int number2) { StartCoroutine(DoNumberAnim(number1, number2)); } private IEnumerator DoNumberAnim(int number1, int number2) { int add = number2 - number1; _tmpContent2.text = "+" + add; add /= 16; for (int i = 0; i < 16; i++) { if (number2 - number1 < add) break; number1 = (int)Mathf.Lerp(number1, number2, 0.1f); _tmpContent.text = number1.ToString(); yield return null; yield return null; yield return null; } yield return null; _tmpContent.text = number2.ToString(); ; } /// /// /// /// public void SetImage(int index) { if (_imgFrame) _imgFrame.ShowSprite(index); } /// /// /// /// public void SetQuality(int quality) { var color = Item.GetQualityColor(quality); if (_imgFrame) _imgFrame.ShowSprite(quality - 3); if (_tmpContent) _tmpContent.color = color; } /// /// /// /// public void SetIcon(string[] iconInfo) { if (_imgIcon) IconProxy.Instance.SetSprite(_imgIcon, iconInfo); } public void SetAlpha(float alpha) { if (_canvasGroup) _canvasGroup.alpha = alpha; } public void SetFx(string fx) { for (int i = 0; i < transform.childCount; i++) { var child = transform.GetChild(i); child.gameObject.SetActive(child.name == fx); } } #endregion #region Unity /// /// /// private void Awake() { SetViewData(); _canvasGroup = GetComponent(); } #endregion } } }