Skip to content

Instantly share code, notes, and snippets.

@hiroakioishi
Last active February 5, 2024 05:04
Show Gist options
  • Select an option

  • Save hiroakioishi/aa4c24788a2e96da7a5a8fecbeede684 to your computer and use it in GitHub Desktop.

Select an option

Save hiroakioishi/aa4c24788a2e96da7a5a8fecbeede684 to your computer and use it in GitHub Desktop.
Unity: アプリケーションの二重起動防止
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