当前位置:网站首页>Unity script API - time class
Unity script API - time class
2022-07-04 15:22:00 【@Night Charm】
Time class :
1、 from Unity Interface for obtaining time information
2、 Common properties :
time: The time taken from the beginning of the game to the present
timeScale: Time scaling
deltaTime: In seconds , Represents the elapsed time of each frame
unscaledDeltaTime: Elapsed time per frame unaffected by scaling
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
///
/// </summary>
public class TimeDemo : MonoBehaviour
{
public int speed = 100;
public float a,b,c;
public int count;
public float du;
public int timeVsCount;
public int duVsCount;
// When rendering a scene , Not subject to TimeScale influence
public void Update()
{
a = Time.time;// Game run time affected by scaling
b = Time.unscaledTime;// Game run time unaffected by scaling
c = Time.realtimeSinceStartup;// Actual game run time
// Every rendered frame perform 1 Time rotate 1 degree
//1 second rotate ? degree 1 Number of frames rotated in seconds In the same case
// Multiple frames 1 Second rotation speed is fast hope 1 Frame rotation is small
// Less slow Big
this.transform.Rotate(0, speed * Time.deltaTime,0);
// Game pause , Individual objects are not affected Time.unscaledDeltaTime: Every frame interval unaffected by scaling
this.transform.Rotate(0, speed * Time.unscaledDeltaTime, 0);
// rotate / Movement speed * Time consumed per frame , Rotation can be guaranteed / The moving speed is not affected by the machine performance , And rendering effects
count++;
du += speed * Time.deltaTime;
if (a >= 1 && timeVsCount < 1)
{
//speed:100 1 Second rendering 76 Time
//speed:200 1 Second rendering 66 Time
Debug.Log(" The game frame is rendered "+count+" Time ");
Debug.Log(" The game object rotates " + du + " degree ");
Debug.Log(Time.deltaTime);
timeVsCount++;
}
if (du >= 360 && duVsCount < 1)
{
Debug.Log(" The game object rotates for one circle , The total amount of rendering is " + count + " Time ");
Debug.Log(" The game object rotates " + du + " degree ");
Debug.Log(Time.deltaTime);
duVsCount++;
}
}
// Fix 0.02 second Do it once It has nothing to do with rendering , suffer TimeScale influence
public void FixedUpdate()
{
this.transform.Rotate(0,speed,0);
}
// Game pause
private void OnGUI()
{
if (GUILayout.Button(" Pause the game "))
{
Time.timeScale = 0;
}
if (GUILayout.Button(" Keep playing "))
{
Time.timeScale = 1;
}
}
}
边栏推荐
- Unity update process_ Principle of unity synergy
- Deep learning network regularization
- Korean AI team plagiarizes shock academia! One tutor with 51 students, or plagiarism recidivist
- Implementation of web chat room
- MySQL组合索引(多列索引)使用与优化案例详解
- Decimal, exponential
- Unity脚本API—Time类
- PXE网络
- Redis 發布和訂閱
- 31年前的Beyond演唱会,是如何超清修复的?
猜你喜欢

Ffprobe common commands

压力、焦虑还是抑郁? 正确诊断再治疗

Introduction to modern control theory + understanding

Analysis of nearly 100 million dollars stolen and horizon cross chain bridge attacked

Unity脚本常用API Day03

Force button brush question 01 (reverse linked list + sliding window +lru cache mechanism)

MySQL学习笔记——数据类型(2)

数据湖治理:优势、挑战和入门

Techsmith Camtasia Studio 2022.0.2屏幕录制软件

Who the final say whether the product is good or not? Sonar puts forward performance indicators for analysis to help you easily judge product performance and performance
随机推荐
Halcon knowledge: NCC_ Model template matching
Solve the error of JSON module in PHP compilation and installation under CentOS 6.3
How to build a technical team that will bring down the company?
Guitar Pro 8win10 latest guitar learning / score / creation
Unity脚本介绍 Day01
selenium 浏览器(2)
LeetCode 35. Search the insertion position - vector traversal (O (logn) and O (n) - binary search)
Techsmith Camtasia Studio 2022.0.2屏幕录制软件
go-zero微服务实战系列(九、极致优化秒杀性能)
Deep learning network regularization
UFO: Microsoft scholars have proposed a unified transformer for visual language representation learning to achieve SOTA performance on multiple multimodal tasks
Live broadcast preview | PostgreSQL kernel Interpretation Series II: PostgreSQL architecture
压力、焦虑还是抑郁? 正确诊断再治疗
MySQL~MySQL给已有的数据表添加自增ID
Redis sentinel mode realizes one master, two slave and three Sentinels
mysql 联合主键_Mysql 创建联合主键[通俗易懂]
They are all talking about Devops. Do you really understand it?
What is the future of the booming intelligent Internet of things (aiot) in recent years?
LeetCode 58. 最后一个单词的长度
浮点数如何与0进行比较?