StopApplicationFromConfig.cs 575 B

12345678910111213141516171819202122232425
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class StopApplicationFromConfig : MonoBehaviour
  5. {
  6. public ConfigReader Config;
  7. private float totaltime;
  8. private float currenttime = 0f;
  9. void Start()
  10. {
  11. totaltime = Config.configuration.SimulationTime;
  12. }
  13. private void Update()
  14. {
  15. currenttime += Time.deltaTime;
  16. if (currenttime > totaltime)
  17. {
  18. // stop the application (does not work in the Editor, only for builds)
  19. Application.Quit();
  20. }
  21. }
  22. }