Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion getting_started/first_2d_game/03.coding_the_player.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ Start by declaring the member variables this object will need:
.. code-tab:: csharp

using Godot;
using System;

public partial class Player : Area2D
{
Expand Down
4 changes: 3 additions & 1 deletion getting_started/first_2d_game/04.creating_the_enemy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ Add a script to the ``Mob`` like this:

.. code-tab:: csharp

public class Mob : RigidBody2D
using Godot;

public partial class Mob : RigidBody2D
{
// Don't forget to rebuild the project.
}
Expand Down
4 changes: 3 additions & 1 deletion getting_started/first_2d_game/06.heads_up_display.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ Now add this script to ``HUD``:

.. code-tab:: csharp

public class HUD : CanvasLayer
using Godot;

public partial class HUD : CanvasLayer
{
// Don't forget to rebuild the project so the editor knows about the new signal.

Expand Down
8 changes: 4 additions & 4 deletions getting_started/step_by_step/signals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Your complete ``Sprite2D.gd`` code should look like the following.

using Godot;

public class Sprite : Godot.Sprite2D
public partial class Sprite : Sprite2D
{
private float Speed = 400;
private float AngularSpeed = Mathf.Pi;
Expand Down Expand Up @@ -370,7 +370,7 @@ Here is the complete ``Sprite2D.gd`` file for reference.

using Godot;

public class Sprite : Godot.Sprite2D
public partial class Sprite : Sprite2D
{
private float Speed = 400;
private float AngularSpeed = Mathf.Pi;
Expand Down Expand Up @@ -423,7 +423,7 @@ reaches 0.

using Godot;

public class CustomSignal : Node2D
public partial class CustomSignal : Node2D
{
[Signal]
public delegate void HealthDepletedEventHandler();
Expand Down Expand Up @@ -477,7 +477,7 @@ names between parentheses:

using Godot;

public class CustomSignal : Node
public partial class CustomSignal : Node
{
[Signal]
public delegate void HealthChangedEventHandler(int oldValue, int newValue);
Expand Down
4 changes: 0 additions & 4 deletions tutorials/2d/2d_movement.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Add a script to the character body and add the following code:
.. code-tab:: csharp

using Godot;
using System;

public partial class Movement : CharacterBody2D
{
Expand Down Expand Up @@ -123,7 +122,6 @@ while up/down moves it forward or backward in whatever direction it's facing.
.. code-tab:: csharp

using Godot;
using System;

public partial class Movement : CharacterBody2D
{
Expand Down Expand Up @@ -182,7 +180,6 @@ is set by the mouse position instead of the keyboard. The character will always
.. code-tab:: csharp

using Godot;
using System;

public partial class Movement : CharacterBody2D
{
Expand Down Expand Up @@ -246,7 +243,6 @@ on the screen will cause the player to move to the target location.
.. code-tab:: csharp

using Godot;
using System;

public partial class Movement : CharacterBody2D
{
Expand Down
8 changes: 6 additions & 2 deletions tutorials/2d/2d_sprite_animation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ released.

.. code-tab:: csharp

public class Character : CharacterBody2D
using Godot;

public partial class Character : CharacterBody2D
{
private AnimatedSprite2D _animatedSprite;

Expand Down Expand Up @@ -227,7 +229,9 @@ released.

.. code-tab:: csharp

public class Character : CharacterBody2D
using Godot;

public partial class Character : CharacterBody2D
{
private AnimationPlayer _animationPlayer;

Expand Down
12 changes: 9 additions & 3 deletions tutorials/2d/custom_drawing_in_2d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ redrawn if modified:

.. code-tab:: csharp

public class CustomNode2D : Node2D
using Godot;

public partial class CustomNode2D : Node2D
{
private Texture _texture;
public Texture Texture
Expand Down Expand Up @@ -122,7 +124,9 @@ call ``queue_redraw()`` from the ``_process()`` callback, like this:

.. code-tab:: csharp

public class CustomNode2D : Node2D
using Godot;

public partial class CustomNode2D : Node2D
{
public override void _Draw()
{
Expand Down Expand Up @@ -326,7 +330,9 @@ using ``get_node()``.

.. code-tab:: csharp

public class CustomNode2D : Node2D
using Godot;

public partial class CustomNode2D : Node2D
{
private float _rotationAngle = 50;
private float _angleFrom = 75;
Expand Down
4 changes: 3 additions & 1 deletion tutorials/best_practices/data_preferences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ tree structures.

.. code-tab:: csharp

using Godot;

// Can decide whether to expose getters/setters for properties later
public class TreeNode : Object
public partial class TreeNode : Object
{
private TreeNode _parent = null;

Expand Down
8 changes: 6 additions & 2 deletions tutorials/best_practices/godot_interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,9 @@ accesses:
.. code-tab:: csharp

// Child.cs
public class Child : Node
using Godot;

public partial class Child : Node
{
public FuncRef FN = null;

Expand All @@ -493,7 +495,9 @@ accesses:
}

// Parent.cs
public class Parent : Node
using Godot;

public partial class Parent : Node
{
public Node Child;

Expand Down
12 changes: 9 additions & 3 deletions tutorials/best_practices/godot_notifications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ deltatime methods as needed.

.. code-tab:: csharp

public class MyNode : Node
using Godot;

public partial class MyNode : Node
{

// Called every frame, even when the engine detects no input.
Expand Down Expand Up @@ -171,7 +173,9 @@ instantiation:

.. code-tab:: csharp

public class MyNode : Node
using Godot;

public partial class MyNode : Node
{
private string _test = "one";

Expand Down Expand Up @@ -255,7 +259,9 @@ nodes that one might create at runtime.

.. code-tab:: csharp

public class MyNode : Node
using Godot;

public partial class MyNode : Node
{
public Node ParentCache = null;

Expand Down
3 changes: 1 addition & 2 deletions tutorials/best_practices/logic_preferences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ either? Let's see an example:

.. code-tab:: csharp

using System;
using Godot;

// C# and other languages have no concept of "preloading".
public class MyBuildings : Node
public partial class MyBuildings : Node
{
//This is a read-only field, it can only be assigned when it's declared or during a constructor.
public readonly PackedScene Building = ResourceLoader.Load<PackedScene>("res://building.tscn");
Expand Down
4 changes: 2 additions & 2 deletions tutorials/best_practices/scene_organization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ in another context without any extra changes to its API.
// Parent
GetNode<Left>("Left").Target = GetNode("Right/Receiver");

public class Left : Node
public partial class Left : Node
{
public Node Target = null;

Expand All @@ -189,7 +189,7 @@ in another context without any extra changes to its API.
}
}

public class Right : Node
public partial class Right : Node
{
public Node Receiver = null;

Expand Down
54 changes: 26 additions & 28 deletions tutorials/best_practices/scenes_versus_scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,37 @@ But, choosing which one to use can be a dilemma. Creating script instances
is identical to creating in-engine classes whereas handling scenes requires
a change in API:

.. tabs::
.. code-tab:: gdscript GDScript
.. tabs::
.. code-tab:: gdscript GDScript

const MyNode = preload("my_node.gd")
const MyScene = preload("my_scene.tscn")
var node = Node.new()
var my_node = MyNode.new() # Same method call
var my_scene = MyScene.instantiate() # Different method call
var my_inherited_scene = MyScene.instantiate(PackedScene.GEN_EDIT_STATE_MAIN) # Create scene inheriting from MyScene
const MyNode = preload("my_node.gd")
const MyScene = preload("my_scene.tscn")
var node = Node.new()
var my_node = MyNode.new() # Same method call
var my_scene = MyScene.instantiate() # Different method call
var my_inherited_scene = MyScene.instantiate(PackedScene.GEN_EDIT_STATE_MAIN) # Create scene inheriting from MyScene

.. code-tab:: csharp
.. code-tab:: csharp

using System;
using Godot;
using Godot;

public class Game : Node
public partial class Game : Node
{
public readonly Script MyNodeScr = (Script)ResourceLoader.Load("MyNode.cs");
public readonly PackedScene MySceneScn = (PackedScene)ResourceLoader.Load("MyScene.tscn");
public Node ANode;
public Node MyNode;
public Node MyScene;
public Node MyInheritedScene;

public Game()
{
public readonly Script MyNodeScr = (Script)ResourceLoader.Load("MyNode.cs");
public readonly PackedScene MySceneScn = (PackedScene)ResourceLoader.Load("MyScene.tscn");
public Node ANode;
public Node MyNode;
public Node MyScene;
public Node MyInheritedScene;

public Game()
{
ANode = new Node();
MyNode = new MyNode(); // Same syntax
MyScene = MySceneScn.Instantiate(); // Different. Instantiated from a PackedScene
MyInheritedScene = MySceneScn.Instantiate(PackedScene.GenEditState.Main); // Create scene inheriting from MyScene
}
ANode = new Node();
MyNode = new MyNode(); // Same syntax
MyScene = MySceneScn.Instantiate(); // Different. Instantiated from a PackedScene
MyInheritedScene = MySceneScn.Instantiate(PackedScene.GenEditState.Main); // Create scene inheriting from MyScene
}
}

Also, scripts will operate a little slower than scenes due to the
speed differences between engine and script code. The larger and more complex
Expand Down Expand Up @@ -161,10 +160,9 @@ with it, and finally adds it as a child of the ``Main`` node:

.. code-tab:: csharp

using System;
using Godot;

public class Main : Resource
public partial class Main : Resource
{
public Node Child { get; set; }

Expand Down
6 changes: 2 additions & 4 deletions tutorials/inputs/input_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ attach the following script:
.. code-tab:: csharp

using Godot;
using System;

public class Node : Godot.Node
public partial class Node : Godot.Node
{
public override void _Input(InputEvent inputEvent)
{
Expand Down Expand Up @@ -346,9 +345,8 @@ node:
.. code-tab:: csharp

using Godot;
using System;

public class Node2D : Godot.Node2D
public partial class Node2D : Godot.Node2D
{
private bool dragging = false;
private int clickRadius = 32; // Size of the sprite.
Expand Down
4 changes: 3 additions & 1 deletion tutorials/networking/http_client_class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ It will connect and fetch a website.

.. code-tab:: csharp

class HTTPTest : SceneTree
using Godot;

public partial class HTTPTest : SceneTree
{
// HTTPClient demo.
// This simple class can make HTTP requests; it will not block, but it needs to be polled.
Expand Down
4 changes: 3 additions & 1 deletion tutorials/networking/http_request_class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ Below is all the code we need to make it work. The URL points to an online API m

.. code-tab:: csharp

class HTTPRequestDemo : CanvasLayer
using Godot;

public partial class HTTPRequestDemo : CanvasLayer
{
public override void _Ready()
{
Expand Down
3 changes: 1 addition & 2 deletions tutorials/performance/using_multimesh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ efficient for millions of objects, but for a few thousands, GDScript should be f
.. code-tab:: csharp C#

using Godot;
using System;

public class YourClassName : MultiMeshInstance3D
public partial class YourClassName : MultiMeshInstance3D
{
public override void _Ready()
{
Expand Down
Loading