Skip to content

Commit

Permalink
Merge pull request #89246 from AThousandShips/dotnet_name
Browse files Browse the repository at this point in the history
[Docs][C#] Use `PropertyName` constants in more places
  • Loading branch information
akien-mga committed Mar 7, 2024
2 parents dd90c3c + 2f1f8ee commit aef11a1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions doc/classes/Object.xml
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@
[csharp]
var node = new Node2D();
node.Rotation = 1.5f;
var a = node.Get("rotation"); // a is 1.5
var a = node.Get(Node2D.PropertyName.Rotation); // a is 1.5
[/csharp]
[/codeblocks]
[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.
Expand Down Expand Up @@ -911,7 +911,7 @@
[/gdscript]
[csharp]
var node = new Node2D();
node.Set("global_scale", new Vector2(8, 2.5));
node.Set(Node2D.PropertyName.GlobalScale, new Vector2(8, 2.5));
GD.Print(node.GlobalScale); // Prints Vector2(8, 2.5)
[/csharp]
[/codeblocks]
Expand All @@ -936,21 +936,21 @@
var node = Node2D.new()
add_child(node)

node.rotation = 45.0
node.set_deferred("rotation", 90.0)
print(node.rotation) # Prints 45.0
node.rotation = 1.5
node.set_deferred("rotation", 3.0)

This comment has been minimized.

Copy link
@conde2

conde2 Mar 7, 2024

I belive you missied this one:
node.SetDeferred(Node2D.PropertyName.Rotation, 3f);

This comment has been minimized.

Copy link
@luevano

luevano Mar 7, 2024

Contributor

Isn't this below on line 949?

This comment has been minimized.

Copy link
@conde2

conde2 Mar 7, 2024

You are right, I'm sorry, this one is for GDScript

print(node.rotation) # Prints 1.5

await get_tree().process_frame
print(node.rotation) # Prints 90.0
print(node.rotation) # Prints 3.0
[/gdscript]
[csharp]
var node = new Node2D();
node.Rotation = 45f;
node.SetDeferred("rotation", 90f);
GD.Print(node.Rotation); // Prints 45.0
node.Rotation = 1.5f;
node.SetDeferred(Node2D.PropertyName.Rotation, 3f);
GD.Print(node.Rotation); // Prints 1.5

await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
GD.Print(node.Rotation); // Prints 90.0
GD.Print(node.Rotation); // Prints 3.0
[/csharp]
[/codeblocks]
[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.
Expand Down

0 comments on commit aef11a1

Please sign in to comment.