[Docs][C#] Use `PropertyName` constants in more places

(cherry picked from commit 2f1f8ee39b)
This commit is contained in:
A Thousand Ships 2024-03-07 13:00:34 +01:00 committed by Rémi Verschelde
parent 962575ad73
commit c2ff91c418
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 10 additions and 10 deletions

View File

@ -561,7 +561,7 @@
[csharp] [csharp]
var node = new Node2D(); var node = new Node2D();
node.Rotation = 1.5f; 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] [/csharp]
[/codeblocks] [/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. [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.
@ -828,7 +828,7 @@
[/gdscript] [/gdscript]
[csharp] [csharp]
var node = new Node2D(); 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) GD.Print(node.GlobalScale); // Prints Vector2(8, 2.5)
[/csharp] [/csharp]
[/codeblocks] [/codeblocks]
@ -853,21 +853,21 @@
var node = Node2D.new() var node = Node2D.new()
add_child(node) add_child(node)
node.rotation = 45.0 node.rotation = 1.5
node.set_deferred("rotation", 90.0) node.set_deferred("rotation", 3.0)
print(node.rotation) # Prints 45.0 print(node.rotation) # Prints 1.5
await get_tree().process_frame await get_tree().process_frame
print(node.rotation) # Prints 90.0 print(node.rotation) # Prints 3.0
[/gdscript] [/gdscript]
[csharp] [csharp]
var node = new Node2D(); var node = new Node2D();
node.Rotation = 45f; node.Rotation = 1.5f;
node.SetDeferred("rotation", 90f); node.SetDeferred(Node2D.PropertyName.Rotation, 3f);
GD.Print(node.Rotation); // Prints 45.0 GD.Print(node.Rotation); // Prints 1.5
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
GD.Print(node.Rotation); // Prints 90.0 GD.Print(node.Rotation); // Prints 3.0
[/csharp] [/csharp]
[/codeblocks] [/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. [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.