您当前的位置: 首页 >  unity

云小川

暂无认证

  • 5浏览

    0关注

    78博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Unity将时间转换成 小时:分钟:秒 格式

云小川 发布时间:2021-08-27 11:26:23 ,浏览量:5

原地址:(3条消息) Unity将时间转换成 小时:分钟:秒 格式_a451319296的博客-CSDN博客

记录一下:

/*******************************************************************************************************************************************************************************                                                                                                                            _ooOoo_                                                                                  o8888888o                                                                            88" . "88                                                                                 (| -_- |)                                                                            O\  =  /O                                                                         ____/`---'\____                                                                       .'  \\|     |//  `.                                                                      /  \\|||  :  |||//  \                                                                     /  _||||| -:- |||||-  \                                                                     |   | \\\  -  /// |   |d                                                                     | \_|  ''\---/''  |   |                                                                     \  .-\__  `-`  ___/-. /                                                                   ___`. .'  /--.--\  `. . __                                                                ."" '<  `.___\__/___.'  >'"".                                                               | | :  `- \`.;`\ _ /`;.`/ - ` : | |                                                               \  \ `-.   \_ __\ /__ _/   .-` /  /                                                           =====`-.____`-.___\_____/___.-`____.-'======                                                                             `=---='                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                   \     |     /                                                                           \    |    /                                                                            \   |   /                                                                             \  |  /                                                                        \\             //                                                                         \\___________//                                                                                                                                              佛祖保佑       永无Bug                                                                     快加工资       不改需求                                                                             阿弥陀佛 *本模块已经经过开光处理,绝无可能再产生bug *作者: TianWenQuan *日期: #CreateTime# ********************************************************************************************************************************************************************************/ using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;

public class TimeZhuanHuan : MonoBehaviour {     public Button button;     bool bo = true;     float time_ = 0;     void Start()     {         Debug.Log("时间="+ FormatTime(time_));         button.onClick.AddListener(()=> {           //  bo = false;             Debug.Log("时间02=" + FormatTime(time_));         });     }

    void Update()     {         if (bo)         {             time_ += Time.deltaTime;         }     }     ///     /// 格式化时间     ///     /// 秒     ///     public static string FormatTime(float seconds)     {         TimeSpan ts = new TimeSpan(0, 0, Convert.ToInt32(seconds));         string str = "";

        if (ts.Hours > 0)         {             str = ts.Hours.ToString("00") + ":" + ts.Minutes.ToString("00") + ":" + ts.Seconds.ToString("00");         }         if (ts.Hours == 0 && ts.Minutes > 0)         {             str = "00:" + ts.Minutes.ToString("00") + ":" + ts.Seconds.ToString("00");         }         if (ts.Hours == 0 && ts.Minutes == 0)         {             str = "00:" + "00:" + ts.Seconds.ToString("00");         }

        return str;     } }  

关注
打赏
1663746399
查看更多评论
立即登录/注册

微信扫码登录

0.1997s