From e09439a4e087e96d8064935329a5707974b8240e Mon Sep 17 00:00:00 2001 From: Shawn Hardern <126725649+ShawnHardern@users.noreply.github.com> Date: Sun, 25 Aug 2024 12:12:49 +0100 Subject: [PATCH] Add missing C# code examples to documentation Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-authored-by: Raul Santos --- about/introduction.rst | 10 +- tutorials/i18n/internationalizing_games.rst | 38 +- .../io/runtime_file_loading_and_saving.rst | 162 +++++++- .../navigation_connecting_navmesh.rst | 28 ++ .../navigation/navigation_debug_tools.rst | 7 +- .../navigation_different_actor_locomotion.rst | 48 ++- .../navigation_different_actor_types.rst | 66 +++ .../navigation_using_navigationagents.rst | 375 ++++++++++++++++++ .../navigation_using_navigationlayers.rst | 100 +++++ .../navigation_using_navigationlinks.rst | 72 ++++ .../navigation_using_navigationmeshes.rst | 212 +++++++++- .../navigation_using_navigationobstacles.rst | 94 +++++ .../navigation_using_navigationpaths.rst | 118 ++++++ tutorials/performance/thread_safe_apis.rst | 22 +- tutorials/performance/using_servers.rst | 35 ++ tutorials/physics/ragdoll_system.rst | 7 + tutorials/physics/ray-casting.rst | 18 + 17 files changed, 1385 insertions(+), 27 deletions(-) diff --git a/about/introduction.rst b/about/introduction.rst index c3314f475..717bbf20f 100644 --- a/about/introduction.rst +++ b/about/introduction.rst @@ -5,11 +5,19 @@ Introduction ============ -:: +.. tabs:: + .. code-tab:: gdscript func _ready(): print("Hello world!") + .. code-tab:: csharp + + public override void _Ready() + { + GD.Print("Hello world!"); + } + Welcome to the official documentation of **Godot Engine**, the free and open source community-driven 2D and 3D game engine! Behind this mouthful, you will find a powerful yet user-friendly tool that you can use to develop any kind of game, diff --git a/tutorials/i18n/internationalizing_games.rst b/tutorials/i18n/internationalizing_games.rst index 18cc299cd..afffbd0a1 100644 --- a/tutorials/i18n/internationalizing_games.rst +++ b/tutorials/i18n/internationalizing_games.rst @@ -75,11 +75,17 @@ Translate** in the inspector. In code, the :ref:`Object.tr() ` function can be used. This will just look up the text in the translations and convert it if found: -:: +.. tabs:: + .. code-tab:: gdscript level.text = tr("LEVEL_5_NAME") status.text = tr("GAME_STATUS_%d" % status_index) + .. code-tab:: csharp + + level.Text = Tr("LEVEL_5_NAME"); + status.Text = Tr($"GAME_STATUS_{statusIndex}"); + .. note:: If no text is displayed after changing the language, try to use a different @@ -105,7 +111,8 @@ allows translations to sound more natural. Named placeholders with the ``String.format()`` function should be used whenever possible, as they also allow translators to choose the *order* in which placeholders appear: -:: +.. tabs:: + .. code-tab:: gdscript # The placeholder's locations can be changed, but not their order. # This will probably not suffice for some target languages. @@ -125,7 +132,8 @@ optionally specify a *translation context* to resolve this ambiguity and allow target languages to use different strings, even though the source string is identical: -:: +.. tabs:: + .. code-tab:: gdscript # "Close", as in an action (to close something). button.set_text(tr("Close", "Actions")) @@ -133,6 +141,14 @@ identical: # "Close", as in a distance (opposite of "far"). distance_label.set_text(tr("Close", "Distance")) + .. code-tab:: csharp + + // "Close", as in an action (to close something). + GetNode