How to enable and disable back game object for ui button after a few seconds?

Hello,

i`m beginer in programing or unity, i want to make script for enable and disable back after a few sec for UI button. i founded this script:

using UnityEngine;
using System.Collections;

public class ActiveStateToggler : MonoBehaviour {

	public void ToggleActive () {
		gameObject.SetActive (!gameObject.activeSelf);
	}
}

but this script wil enable with 1 click and disable after i click again.

What i should add into script? WaitForSeconds?

ps: I used Unity 5.2 and i used C#

sorry for bad english.

You’ll need to use a Coroutine. You can use something like this:

public void ToggleActive() {
    StartCoroutine(Reverse());
}


IENumerator Reverse() {
    yield return new WaitForSeconds(1f); //Wait 1 second
    gameObject.SetActive(!gameObject.activeSelf);
}