MonoBehaviour.Update()

Açıklama

Update, MonoBehaviour etkinleştirildiyse her karede çağrılır.

Update, her tür oyun komut dosyası uygulamak için en yaygın kullanılan işlevdir. Her MonoBehaviour komut dosyası Update'i gerektirmez.

using UnityEngine;
using System.Collections;

// ExampleClass, Awake ile başlar. GameObject sınıfının activeSelf özelliği false olarak
// ayarlanmıştır. activeSelf true olarak ayarlandığında Start() ve Update() işlevleri 
// çağrılır ve ExampleClass çalışır.
// Dikkat edilmesi gereken nokta, ExampleClass (Script) Inspector'da devre dışı 
// bırakılmıştır. Start işlevinin çağrılması için işaretlenmesi gerekmektedir.

public class ExampleClass : MonoBehaviour
{
    private float update;

    void Awake()
    {
        Debug.Log("Awake");
        update = 0.0f;
    }

    IEnumerator Start()
    {
        Debug.Log("Start1");
        yield return new WaitForSeconds(2.5f);
        Debug.Log("Start2");
    }

    void Update()
    {
        update += Time.deltaTime;

        if (update > 1.0f)
        {
            update = 0.0f;
            Debug.Log("Update");
        }
    }
}


Bu blog Unity Docs'un Türkçeye çevrilmiş halidir.

Yorumlar

Bu blogdaki popüler yayınlar

Important Classes - Vectors

RequireComponent

Important Classes - GameObject