S
S
Stanislav Ivanov2020-05-10 23:29:42
Unity
Stanislav Ivanov, 2020-05-10 23:29:42

How to make a button active to be clicked only after a certain time has elapsed?

I have a button, there is a script for clicking. But I need the ability to click on the button to be available only when, well, let's say 3 seconds pass. How can this be implemented?

The description of the button component itself with the click script attached - https://skr.sh/s26gkLaBEib?a

The script itself (just a transition to the next scene):

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

public class Trans_Mini_Game : MonoBehaviour
{
    public float time_s;

    public void Transistion()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DanielMcRon, 2020-05-11
@Sterio23400

Counter, take a variable for the time, in Update subtract Time.DeltaTime from it, if this time is less than or equal to 0, then make the button available. When some action occurs, you set a new variable with a time of 3, for example, and make the button inactive

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question