Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Visual Studio

Visual Studio Community is a Windows-only IDE by Microsoft that's free for individual use or non-commercial use within organizations. It has many useful features, such as memory view, performance view, source control and more.

Importation du projet

Visual Studio a besoin d'un fichier de solution pour travailler sur un projet. Bien que Godot ne soit pas fourni avec le fichier de solution, il peut être généré à l'aide de SCons.

  • Naviguez jusqu'au dossier racine de Godot et ouvrez une fenêtre d'invite de commande ou une fenêtre PowerShell.

  • Run scons platform=windows vsproj=yes dev_build=yes to generate the solution with debug symbols.
    The vsproj parameter signals that you want Visual Studio solution generated.
    The dev_build parameter makes sure the debug symbols are included, allowing to e.g. step through code using breakpoints.
  • Vous pouvez maintenant ouvrir le projet en double-cliquant sur le godot.sln dans la racine du projet ou en utilisant l'option Open a project or solution à l'intérieur de Visual Studio.

  • Utilisez le menu supérieur Build pour compiler le projet.

Avertissement

Visual Studio must be configured with the C++ package. It can be selected in the installer:

../../../_images/vs_1_install_cpp_package.png

Débogage du projet

Visual Studio dispose d'un puissant débogueur. Il permet à l'utilisateur d'examiner le code source de Godot, de s'arrêter à des points précis du code, d'inspecter le contexte d'exécution actuel et d'apporter des modifications en direct à la base de code.

You can launch the project with the debugger attached using the Debug > Start Debugging option from the top menu. However, unless you want to debug the Project Manager specifically, you'd need to configure debugging options first. This is due to the fact that when the Godot Project Manager opens a project, the initial process is terminated and the debugger gets detached.

  • Pour configurer les options de lancement à utiliser avec le débogueur, utilisez Project > Properties dans le menu du haut :

../../../_images/vs_2_project_properties.png
  • Open the Debugging section and under Command Arguments add two new arguments: the -e flag opens the editor instead of the Project Manager, and the --path argument tells the executable to open the specified project (must be provided as an absolute path to the project root, not the project.godot file; if the path contains spaces be sure to pass it inside double quotation marks).

../../../_images/vs_3_debug_command_line.webp

Pour en savoir plus sur les arguments de la ligne de commande, reportez-vous au tutoriel de la ligne de commande.

Même si vous démarrez le projet sans débogueur attaché, il peut toujours être connecté au processus en cours en utilisant le menu Debug > Attach to Process....

Pour vérifier que tout fonctionne, mettez un breakpoint dans main.cpp et appuyez sur F5 pour commencer le débogage.

../../../_images/vs_4_debugging_main.png

Si vous rencontrez des problèmes, demandez de l'aide sur l'un des canaux communautaires de Godot.