Skip to content

Commit aef11a1

Browse files
committed
Merge pull request #89246 from AThousandShips/dotnet_name
[Docs][C#] Use `PropertyName` constants in more places
2 parents dd90c3c + 2f1f8ee commit aef11a1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

doc/classes/Object.xml

+10-10
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@
643643
[csharp]
644644
var node = new Node2D();
645645
node.Rotation = 1.5f;
646-
var a = node.Get("rotation"); // a is 1.5
646+
var a = node.Get(Node2D.PropertyName.Rotation); // a is 1.5
647647
[/csharp]
648648
[/codeblocks]
649649
[b]Note:[/b] In C#, [param property] must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the [code]PropertyName[/code] class to avoid allocating a new [StringName] on each call.
@@ -911,7 +911,7 @@
911911
[/gdscript]
912912
[csharp]
913913
var node = new Node2D();
914-
node.Set("global_scale", new Vector2(8, 2.5));
914+
node.Set(Node2D.PropertyName.GlobalScale, new Vector2(8, 2.5));
915915
GD.Print(node.GlobalScale); // Prints Vector2(8, 2.5)
916916
[/csharp]
917917
[/codeblocks]
@@ -936,21 +936,21 @@
936936
var node = Node2D.new()
937937
add_child(node)
938938

939-
node.rotation = 45.0
940-
node.set_deferred("rotation", 90.0)
941-
print(node.rotation) # Prints 45.0
939+
node.rotation = 1.5
940+
node.set_deferred("rotation", 3.0)
941+
print(node.rotation) # Prints 1.5
942942

943943
await get_tree().process_frame
944-
print(node.rotation) # Prints 90.0
944+
print(node.rotation) # Prints 3.0
945945
[/gdscript]
946946
[csharp]
947947
var node = new Node2D();
948-
node.Rotation = 45f;
949-
node.SetDeferred("rotation", 90f);
950-
GD.Print(node.Rotation); // Prints 45.0
948+
node.Rotation = 1.5f;
949+
node.SetDeferred(Node2D.PropertyName.Rotation, 3f);
950+
GD.Print(node.Rotation); // Prints 1.5
951951

952952
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
953-
GD.Print(node.Rotation); // Prints 90.0
953+
GD.Print(node.Rotation); // Prints 3.0
954954
[/csharp]
955955
[/codeblocks]
956956
[b]Note:[/b] In C#, [param property] must be in snake_case when referring to built-in Godot properties. Prefer using the names exposed in the [code]PropertyName[/code] class to avoid allocating a new [StringName] on each call.

0 commit comments

Comments
 (0)