|
643 | 643 | [csharp]
|
644 | 644 | var node = new Node2D();
|
645 | 645 | 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 |
647 | 647 | [/csharp]
|
648 | 648 | [/codeblocks]
|
649 | 649 | [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 | 911 | [/gdscript]
|
912 | 912 | [csharp]
|
913 | 913 | 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)); |
915 | 915 | GD.Print(node.GlobalScale); // Prints Vector2(8, 2.5)
|
916 | 916 | [/csharp]
|
917 | 917 | [/codeblocks]
|
|
936 | 936 | var node = Node2D.new()
|
937 | 937 | add_child(node)
|
938 | 938 |
|
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 |
942 | 942 |
|
943 | 943 | await get_tree().process_frame
|
944 |
| - print(node.rotation) # Prints 90.0 |
| 944 | + print(node.rotation) # Prints 3.0 |
945 | 945 | [/gdscript]
|
946 | 946 | [csharp]
|
947 | 947 | 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 |
951 | 951 |
|
952 | 952 | await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
953 |
| - GD.Print(node.Rotation); // Prints 90.0 |
| 953 | + GD.Print(node.Rotation); // Prints 3.0 |
954 | 954 | [/csharp]
|
955 | 955 | [/codeblocks]
|
956 | 956 | [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