コード例 #1
0
    public static void killProcesses()
    {
        GameLauncherSettings gls = GameObject.FindObjectOfType <GameLauncherSettings>();

        if (gls)
        {
            if (gls.enterPlayMode && EditorApplication.isPlaying)
            {
                EditorApplication.ExitPlaymode();
            }
        }
        string gameProcName = PlayerSettings.productName;

        //Find valid processes of this game
        Process.GetProcesses().ToList().FindAll(
            proc =>
        {
            try
            {
                return(!proc.HasExited && proc.ProcessName == gameProcName);
            }
            catch
            {
                return(false);
            }
        })
        //And then kill them
        .ForEach(proc => proc.Kill());
    }
コード例 #2
0
    public static void runWindows()
    {//2018-08-10: copied from build()
        int windowCount          = 1;
        GameLauncherSettings gls = GameObject.FindObjectOfType <GameLauncherSettings>();

        if (gls)
        {
            windowCount = gls.clientCount;
            if (gls.resetClients)
            {
                killProcesses();
            }
        }
        else
        {
            Debug.LogWarning(
                "No GameLauncherSettings object found!" +
                " Make a new one or open up the Tools scene to make this tool more useful."
                );
        }
        string extension = "exe";
        string buildName = getBuildNamePath(extension);

        Debug.Log($"Launching: {buildName}");
        for (int i = 0; i < windowCount; i++)
        {
            // Run the game (Process class from System.Diagnostics).
            Process proc = new Process();
            proc.StartInfo.FileName    = buildName;
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
            proc.Start();
        }
    }
コード例 #3
0
    public static void testWindows()
    {
        runWindows();
        GameLauncherSettings gls = GameObject.FindObjectOfType <GameLauncherSettings>();

        if (gls)
        {
            if (gls.enterPlayMode)
            {
                EditorApplication.EnterPlaymode();
            }
        }
    }