当前位置:网站首页>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);
}
}
边栏推荐
- The first topic of ape Anthropology
- This article is good
- 中国艾草行业研究与投资前景预测报告(2022版)
- stm32Cubemx(8):RTC和RTC唤醒中断
- MD5 bypass
- 2021 huashubei mathematical modeling idea + reference + paper
- 2022 thinking of Mathematical Modeling B problem of American college students / analysis of 2022 American competition B problem
- 质量体系建设之路的分分合合
- Emlog blog theme template source code simple good-looking responsive
- Is $20billion a little less? Cisco is interested in Splunk?
猜你喜欢
AutoCAD - lengthening
2022 U.S. college students' mathematical modeling e problem ideas / 2022 U.S. game e problem analysis
AutoCAD -- dimension break
Detailed introduction of OSPF header message
【Leetcode】1352. 最后 K 个数的乘积
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)
Reading and visualization of DICOM, MHD and raw files in medical imaging
Unity parallax infinite scrolling background
Use assimp library to read MTL file data
LeetCode之单词搜索(回溯法求解)
随机推荐
Introduce Hamming distance and calculation examples
[groovy] closure closure (customize closure parameters | customize a single closure parameter | customize multiple closure parameters | specify the default value of closure parameters)
Fluent objects and lists
Unity get component
Special information | real estate and office buildings - 22.1.9
Leetcode 222 number of nodes of complete binary tree
Autocad-- Real Time zoom
中国聚氨酯硬泡市场调研与投资预测报告(2022版)
English topic assignment (26)
Debug insights
China needle coke industry development research and investment value report (2022 Edition)
stm32Cubemx(8):RTC和RTC唤醒中断
Understand encodefloatrgba and decodefloatrgba
Detailed introduction of OSPF header message
计组笔记(1)——校验码、原补码乘除计算、浮点数计算
Special information | finance, accounting, audit - 22.1.23
Unity and database
669. Prune binary search tree ●●
GameObject class and transform class of unity
Common technologies of unity