Ugui achieve text typing effect

Source: Internet
Author: User

Sun Guangdong 2015.6.17

The person familiar with the Ngui will know.

But Ngui made some tedious, interested people can turn Ngui Typewritereffect class Ugui specific, because some of the other scripts, do not love to get.


I'm just simplifying the content. It's enough.


Using system;using unityengine;using unityengine.ui;using unityengine.events;///<summary>/// This script is capable of typing or fading text strings over time. </summary>[requirecomponent (typeof (Text))][addcomponentmenu ("Typewriter Effect")]public class    typewritereffect:monobehaviour{public unityevent MyEvent;    public int charspersecond = 0;             Public AudioClip Maudioclip;    The sound of typing, not to play a word, the beginning of the end of the playback stop the private bool isActive = false;    private float timer;    private string words;    Private Text MText;        void Start () {if (MyEvent = = null) MyEvent = new Unityevent ();        Words = Getcomponent<text> (). Text; Getcomponent<text> (). Text = string.        Empty;        Timer = 0;        IsActive = true;        Charspersecond = Mathf.max (1, Charspersecond);    MText = getcomponent<text> ();        } void Reloadtext () {words = Getcomponent<text> (). Text;    MText = getcomponent<text> ();    } public void OnStart (){Reloadtext ();    IsActive = true; } void Onstartwriter () {if (isActive) {try {mtext.text = words .                Substring (0, (int) (Charspersecond * timer));            Timer + = Time.deltatime;            } catch (Exception) {onfinish ();        }}} void OnFinish () {isActive = false;        Timer = 0;        Getcomponent<text> (). Text = words;        try {myevent.invoke ();        } catch (Exception) {Debug.Log ("problem");    }} void Update () {onstartwriter (); }}

It's not finished.


To use the plug-in TEXTFX introduced the previous few days to implement this feature:










??

Ugui achieve text typing effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.