Skip to content

Conversation

@MtMath
Copy link
Contributor

@MtMath MtMath commented Apr 8, 2023

Ao executar o script para criar e abrir um projeto Unity, o script não encerra corretamente e continua em execução até que o Unity seja fechado. Isso ocorre porque o processo do Unity é iniciado como um processo filho do script, e o execa espera que ele seja concluído antes de prosseguir.

Solução proposta:

Modificar a função openUnityProject da seguinte maneira:

export const openUnityProject = async (unityPath: string, projectPath: string) => {
  const subprocess = execa(unityPath, ["-projectPath", projectPath], {
    detached: true,
    cleanup: false, 
    stdio: "ignore",
  });

  // Waits for a short period of time before deeming the command successful
  await new Promise((resolve) => setTimeout(resolve, 2000));

  // Disassociate the Unity process from the script process
  subprocess.unref();
};

closes #8

Execa Referencias

child process
unref

@MatheusMoura17 MatheusMoura17 merged commit afbc415 into homy-game-studio:master Apr 9, 2023
@github-actions
Copy link

github-actions bot commented Apr 9, 2023

🎉 This PR is included in version 1.1.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@MtMath MtMath deleted the fix-not-exit-process branch April 30, 2025 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Script does not exit correctly when opening Unity project

2 participants