Legacy Documentation: Version 2017.2 (Go to current version)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

MonoBehaviour.Update()

Description

Update is called every frame, if the MonoBehaviour is enabled.

Update is the most commonly used function to implement any kind of game behaviour.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Update() { transform.Translate(0, 0, Time.deltaTime * 1); } }

In order to get the elapsed time since last call to Update, use Time.deltaTime. This function is only called if the Behaviour is enabled. Override this function in order to provide your component's functionality.

对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答