PlayerQuitHandler.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using NUnit.Framework.Interfaces;
  2. using UnityEngine.Networking.PlayerConnection;
  3. using UnityEngine.TestRunner.TestLaunchers;
  4. namespace UnityEngine.TestTools.TestRunner.Callbacks
  5. {
  6. internal class PlayerQuitHandler : MonoBehaviour, ITestRunnerListener
  7. {
  8. public void Start()
  9. {
  10. PlayerConnection.instance.Register(PlayerConnectionMessageIds.quitPlayerMessageId, ProcessPlayerQuiteMessage);
  11. }
  12. private void ProcessPlayerQuiteMessage(MessageEventArgs arg0)
  13. {
  14. //Some platforms don't quit, so we need to disconnect to make sure they will not connect to another editor instance automatically.
  15. PlayerConnection.instance.DisconnectAll();
  16. //XBOX has an error when quitting
  17. if (Application.platform == RuntimePlatform.XboxOne)
  18. {
  19. return;
  20. }
  21. Application.Quit();
  22. }
  23. public void RunStarted(ITest testsToRun)
  24. {
  25. }
  26. public void RunFinished(ITestResult testResults)
  27. {
  28. }
  29. public void TestStarted(ITest test)
  30. {
  31. }
  32. public void TestFinished(ITestResult result)
  33. {
  34. }
  35. }
  36. }