当前位置:网站首页>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);
}
}
边栏推荐
- Group counting notes (1) - check code, original complement multiplication and division calculation, floating point calculation
- [crampon programming] lintcode decoding Encyclopedia - 872 termination process
- 2020-10-27
- AutoCAD - graphic input and output
- PostgreSQL surpasses mysql, and the salary of "the best programming language in the world" is low
- AutoCAD - feature matching
- XSS injection
- 2021 Higher Education Club Cup mathematical modeling national tournament ABCD problem - problem solving ideas
- 【acwing】528. cheese
- 中国艾草行业研究与投资前景预测报告(2022版)
猜你喜欢

AutoCAD - full screen display

CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1

How to choose a panoramic camera that suits you?

Emlog博客主题模板源码简约好看响应式

AutoCAD - isometric annotation

An article takes you to thoroughly understand descriptors

AutoCAD - graphic input and output
![[goweb development] Introduction to authentication modes based on cookies, sessions and JWT tokens](/img/20/5c5550e6dabc76702f0e7ce3bef068.jpg)
[goweb development] Introduction to authentication modes based on cookies, sessions and JWT tokens

Unity parallax infinite scrolling background

669. 修剪二叉搜索树 ●●
随机推荐
2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
介绍汉明距离及计算示例
Is $20billion a little less? Cisco is interested in Splunk?
Redis 排查大 key 的4种方法,优化必备
質量體系建設之路的分分合合
This article is good
2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling
Introduction to JVM principle and process
[crampon game] MC tutorial - first day of survival
中国AS树脂市场调研与投资预测报告(2022版)
AutoCAD - continuous annotation
Introduce Hamming distance and calculation examples
Function overloading
Detailed introduction of OSPF header message
[groovy] closure closure (customize closure parameters | customize a single closure parameter | customize multiple closure parameters | specify the default value of closure parameters)
History of web page requests
[groovy] closure (closure call | closure default parameter it | code example)
A survey of automatic speech recognition (ASR) research
How much do you know about 3DMAX rendering skills and HDRI light sources? Dry goods sharing
mysql审计日志归档