Auto exit script
Hello all. I've been scouring the manual and api and I was wondering if someone could tell me if there was a way that i could implement a line of code (preferably C#) to close the application after a certain amount of time?
Answer by whitenerdyswag · Sep 05, 2016 at 04:31 PM
I changed "private void DoQuit()" to "public void DoQuit()" and it worked.
Answer by doublemax · Sep 04, 2016 at 09:44 PM
void Start ()
{
// directly calling Application.Quit doesn't seem to work
Invoke("DoQuit", 60); // 60 seconds
}
private void DoQuit()
{
Application.Quit();
}
After the application is built, for whatever reason, it doesn't seem to exit on its own. It's not giving me any error messages.
using UnityEngine;
using System.Collections;
public class ApplicationQuit : $$anonymous$$onoBehaviour {
void Start()
{
Invoke("DoQuit", 10);
}
private void DoQuit()
{
Application.Quit();
}
void Update()
{
}
}
Which platform? I tested this under Windows and it works.
Windows. Does it make a difference if it's played in VR?
Your answer
![](https://koobas.hobune.stream/wayback/20220612092205im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Randomized array result from other scipt 2 Answers
Leaderboard Unity [C#] Help 1 Answer
Pickup script not working, pls help 0 Answers
How can I move an object with the Leap Motion? 0 Answers
what is wrong here? 0 Answers