当前位置:网站首页>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);
}
}
边栏推荐
猜你喜欢
Download the details and sequence of the original data access from the ENA database in EBI
669. 修剪二叉搜索树 ●●
JVM 原理和流程简介
The principle of attention mechanism and its application in seq2seq (bahadanau attention)
49 pictures and 26 questions explain in detail what is WiFi?
XSS injection
Panel panel of UI
[groovy] closure (closure call | closure default parameter it | code example)
AutoCAD - Document Management
Rip notes [rip three timers, the role of horizontal segmentation, rip automatic summary, and the role of network]
随机推荐
flutter 对象和列表
2021 huashubei mathematical modeling idea + reference + paper
54. Spiral matrix & 59 Spiral matrix II ●●
Unity synergy
AutoCAD - window zoom
Introduce Hamming distance and calculation examples
2022 thinking of mathematical modeling a problem of American college students / analysis of 2022 American competition a problem
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)
AutoCAD - set layer
AutoCAD - Center zoom
【acwing】528. cheese
[crampon game] MC tutorial - first day of survival
AutoCAD - continuous annotation
【Leetcode】1352. 最后 K 个数的乘积
LeetCode之单词搜索(回溯法求解)
Error statuslogger log4j2 could not find a logging implementation
669. 修剪二叉搜索树 ●●
mysql審計日志歸檔
Solutions and answers for the 2021 Shenzhen cup
The 22nd Spring Festival Gala, an immersive stage for the yuan universe to shine into reality