Answers for "function delay unity"

C#
15

Time delay C# unity

void start()
StartCoroutine(Text());

IEnumerator Text()  //  <-  its a standalone method
{
	Debug.Log("Hello")
    yield return new WaitForSeconds(3)
    Debug.Log("ByeBye")
}
Posted by: Guest on March-07-2020
0

unity add a delay in update function

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OverTime : MonoBehaviour
{
    private bool Timed;
    // Start is called before the first frame update
    void Start()
    {
        StartCoroutine(CountDown(5));
    }

    // Update is called once per frame
    void Update()
    {
        if(!Timed)
        {
            StartCoroutine(CountDown(5));
        }
    }

    IEnumerator CountDown(float RestartAfter)
    {
        Timed = true;
        yield return new WaitForSeconds(RestartAfter);
        print(Time.time);
        Timed = false;
    }
}
Posted by: Guest on August-03-2021

C# Answers by Framework

Browse Popular Code Answers by Language