// start the text label scrolling with the specified text public bool StartScroll(string stringTableKey, float newTime, ScrollEndDelegate callback) { if (null == _root) { _root = NGUITools.FindInParents <UIRoot>(_textLabel.gameObject); } string text; if (null != _root && null != _textLabel && !string.IsNullOrEmpty(stringTableKey) && GlobalStringData.Instance.GeneralStringTable.TryGetValue(stringTableKey, out text)) { if (null != _onScrollEnd) { _onScrollEnd(CalculateCompletion()); _onScrollEnd = null; } _onScrollEnd = callback; _textLabel.text = text; const float Cut = 0f; _textLabelFader.FadeToOpaque(Cut); _yScreenPosition = 0f; _speedPerSecond = 1f / newTime; SetTextPosition(_textLabel, _yScreenPosition); return(true); } return(false); }
private void Update() { if (IsActive()) { Scroll(); SetTextPosition(_textLabel, _yScreenPosition); float completion = CalculateCompletion(); if (completion >= 1f) // if the UILabel has scrolled off the top of the screen { const float Cut = 0f; _textLabelFader.FadeToTransparent(Cut); } _textLabelFader.Update(); // this may be fading out the label if (!IsActive() && null != _onScrollEnd) // if we have faded out or got to the top of the screen { _onScrollEnd(completion); _onScrollEnd = null; } } }