using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TwoButton : MonoBehaviour
{
public int clickedCount = 2;
public float clickedInterval = 0.5f;
private float lastClickedTime = 0;
private float count = 0;
public void OnClicked()
{
float interval = Time.realtimeSinceStartup - lastClickedTime;
if (interval <= clickedInterval)
{
count++;
if (count == clickedCount - 1)
{
Exit();
}
}
else
{
count = 0;
}
lastClickedTime = Time.realtimeSinceStartup;
}
public void Exit()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}
|