Unity3d Ugui's Homemade timer (ii)

Source: Internet
Author: User

Use unity3d5.0 +ugui to make a useful game timer

First, the source code

[CSharp]  View plain copy print?  <summary>  ///  time:2014-4-8  ///  author:gwl  ///  Description: This class is used to handle timing functions, including timing start, pause function   /// </summary>   using unityengine;    using system.collections;   using unityengine.ui;      public  class timer : monobehaviour {             Total time of   public float time_all = 300;//timing (in seconds)         public float time_left;//Time remaining        public bool ispausetime  = false;       public Text time;        // Use this for initialization       void  start  ()  {           time_left = time_all;       }               // Update is called once per frame        void Update  ()  {           if (! Ispausetime) {               if (time_Left  > 0)                     starttimer ();           }                   }        /// <summary>       ///  Start Timing          /// </summary>       void starttimer () {           time_left -= time.deltatime;            time.text = GetTime  (time_left);                   }       ///  <summary>       ///continue the game, this is temporarily added here, later code refactoring when added in Uicontrol          /// </summary>       public void  continuegame () {              isPauseTime  = false;           Time.timeScale  = 1;        }          /// <summary>        ///  Pause Timings        /// </summary>    &nbsP;   public void pausetimer () {            isPauseTime = true;             time.timescale = 0;       }       ///  <summary>

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.