当前位置:网站首页>Unity writes timetables (without UI)
Unity writes timetables (without UI)
2022-07-05 04:55:00 【yaohuiyaoo】
1. Key code
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Test : MonoBehaviour {
// millisecond
private float ms = 0f;
// Hours
private int h = 0;
// branch
private int m = 0;
// second
private int s = 0;
// character string
private string timeStr = string.Empty;
void Update () {
// Accumulate the running time of the game
timer += Time.deltaTime;
// Millisecond is 0-1 Decimals of , exceed 1, Carry clear , Recalculate
if (timer >= 1f) { s++;timer = 0; }
if (s >= 60) { m++;s = 0; }
if (m >= 60) { h++;m = 0; }
if (h >= 99) { h = 0; }
}
private void OnGUI()
{
// Convert a number to a string
timeStr = string.Format("{0}:{1}:{2}", h, m, s);
//GUI style
GUIStyle style= new GUIStyle();
// Set font size
style.fontSize = 100;
//GUI label
GUI.Label(new Rect(10,10,100,200),timeStr,style);
}
}
边栏推荐
- Create a pyGame window with a blue background
- Chapter 6 text processing tools for shell programming (awk)
- Minor spanning tree
- JMeter -- distributed pressure measurement
- Function template
- 2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling
- How to choose a panoramic camera that suits you?
- 【Leetcode】1352. Product of the last K numbers
- 介绍汉明距离及计算示例
- Emlog blog theme template source code simple good-looking responsive
猜你喜欢
"Measuring curve length" of CAD dream drawing
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator
2021 huashubei mathematical modeling idea + reference + paper
2022 thinking of mathematical modeling C problem of American college students / analysis of 2022 American competition C problem
C4D simple cloth (version above R21)
2022 thinking of Mathematical Modeling B problem of American college students / analysis of 2022 American competition B problem
【Leetcode】1352. 最后 K 个数的乘积
54. Spiral matrix & 59 Spiral matrix II ●●
【Leetcode】1352. Product of the last K numbers
Emlog blog theme template source code simple good-looking responsive
随机推荐
Forecast report on research and investment prospects of Chinese wormwood industry (2022 Edition)
[groovy] closure closure (customize closure parameters | customize a single closure parameter | customize multiple closure parameters | specify the default value of closure parameters)
Detailed explanation of the ranking of the best universities
AutoCAD - full screen display
This article is good
Database under unity
Rip notes [rip three timers, the role of horizontal segmentation, rip automatic summary, and the role of network]
Solutions and answers for the 2021 Shenzhen cup
MySQL audit log Archive
Redis 排查大 key 的4种方法,优化必备
flutter 对象和列表
Research and investment forecast report of adamantane industry in China (2022 Edition)
#775 Div.1 B. Integral Array 数学
Difference between singleton and factory pattern
mysql審計日志歸檔
JMeter -- distributed pressure measurement
[groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)
质量体系建设之路的分分合合
3dsmax2018 common operations and some shortcut keys of editable polygons
AutoCAD - feature matching