public void OnceEnd() { try { if (TweenLabel != null) { CheckAndDeleteStr(); TweenPosition tp = TweenLabel.GetComponent <TweenPosition>(); if (tp != null) { tp.ResetToBeginning(); tp.from = m_TweenPosFrom; tp.to = new UnityEngine.Vector3(GetOffsetWidth(), m_TweenPosFrom.y, tp.to.z); tp.duration = DelayTime + strcount * 0.3f; tp.enabled = true; } } if (tipStrDic.Count == 0) { NGUITools.SetActive(TweenLabel, false); } } catch (Exception ex) { ArkCrossEngine.LogicSystem.LogFromGfx("[Error]:Exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
public static void TweenDigitTo(this UILabel label, int toValue, float duration = 0.3f) { TweenLabel tweenLabel = label.gameObject.AddMissingComponent <TweenLabel>(); int outText; bool tryParce = int.TryParse(label.text, out outText); tweenLabel.from = tryParce ? outText : 0; tweenLabel.to = toValue; tweenLabel.duration = duration; tweenLabel.tweenFactor = 0; tweenLabel.enabled = true; }
void GetScreenScrollTip(string info, int num) { try { if (info == null || num == 0) { return; } if (tipStrDic.ContainsKey(info)) { tipStrDic[info].count += num; } else { if (tipStrDic.Count == 0) { tipStrDic.Add(info, new TipCount(--num)); if (TweenLabel != null) { UILabel ul = TweenLabel.GetComponent <UILabel>(); if (ul != null) { ul.text = info; strcount = info.Length; } } } else { tipStrDic.Add(info, new TipCount(num)); } if (!NGUITools.GetActive(TweenLabel)) { NGUITools.SetActive(TweenLabel, true); } TweenPosition tp = TweenLabel.GetComponent <TweenPosition>(); if (tp != null) { tp.ResetToBeginning(); tp.from = m_TweenPosFrom; tp.to = new UnityEngine.Vector3(GetOffsetWidth(), m_TweenPosFrom.y, tp.to.z); tp.duration = DelayTime + strcount * 0.3f; tp.enabled = true; } } } catch (Exception ex) { ArkCrossEngine.LogicSystem.LogFromGfx("[Error]:Exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
float GetOffsetWidth() { float width = 0; UIPanel up = gameObject.GetComponent <UIPanel>(); if (up != null) { width -= up.width; if (TweenLabel != null) { UILabel ul = TweenLabel.GetComponent <UILabel>(); if (ul != null) { width -= ul.width; return(width); } } } return(0f); }
void CheckAndDeleteStr() { if (TweenLabel != null) { UILabel ul = TweenLabel.GetComponent <UILabel>(); if (ul != null && ul.text.Length > 0) { string strtip = ""; List <string> strlist = new List <string>(); foreach (string str in tipStrDic.Keys) { if (str != null) { if (tipStrDic[str].count == 0) { strlist.Add(str); } else { tipStrDic[str].count -= 1; strtip += str; } } } for (int i = 0; i < strlist.Count; ++i) { string str2 = strlist[i]; if (str2 != null && tipStrDic.ContainsKey(str2)) { tipStrDic.Remove(str2); } } ul.text = strtip; strcount = strtip.Length; } } }