Last active
February 5, 2024 05:04
-
-
Save hiroakioishi/aa4c24788a2e96da7a5a8fecbeede684 to your computer and use it in GitHub Desktop.
Unity: アプリケーションの二重起動防止
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| /// <summary> | |
| /// 二重起動を防止する | |
| /// </summary> | |
| public class AvoidDoubleLaunch : MonoBehaviour | |
| { | |
| void Start() | |
| { | |
| string processName = System.Diagnostics.Process.GetCurrentProcess().ProcessName; | |
| if (System.Diagnostics.Process.GetProcessesByName(processName).GetUpperBound(0) > 0) | |
| { | |
| Debug.Log("同じアプリがすでに起動しています."); | |
| Application.Quit(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment