-
-
Notifications
You must be signed in to change notification settings - Fork 20.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port code examples to C# of classes beginning with A and B #40978
Conversation
Fixed issue in Animation.xml Does anybody have an idea, how to parse |
7a00675
to
7f7520e
Compare
d7b10fb
to
2d5cac6
Compare
2d5cac6
to
614c891
Compare
fixed a ton of |
f2d8e2e
to
68cc31a
Compare
4d0ec68
to
aba05db
Compare
@HaSa1002 Since #42000 was merged, you can add array concatentation. I suggest adding these lines: // Array concatenation is not possible with C# arrays, but is with Godot.Collections.Array.
var array1 = new Godot.Collections.Array("One", 2);
var array2 = new Godot.Collections.Array(3, "Four");
GD.Print(array1 + array2); // Prints [One, 2, 3, Four] |
aba05db
to
255ac85
Compare
@aaronfranke Added the array concatentation example and did another review pass. All code examples should compile. I removed the wrong example for Array.sort |
@@ -6,10 +6,16 @@ | |||
<description> | |||
Allows control of [AnimationTree] state machines created with [AnimationNodeStateMachine]. Retrieve with [code]$AnimationTree.get("parameters/playback")[/code]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove the "Retrieve with .." line, since the codeblock shows how to get it. (Or just remove the code
tag)
[codeblock] | ||
[codeblocks] | ||
[gdscript] | ||
var state_machine = $AnimationTree.get("parameters/playback") | ||
state_machine.travel("some_state") | ||
[/codeblock] | ||
[/gdscript] | ||
[csharp] | ||
var stateMachine = GetNode<AnimationTree>("AnimationTree").Get("parameters/playback") as AnimationNodeStateMachinePlayback; | ||
stateMachine.Travel("some_state"); | ||
[/csharp] | ||
[/codeblocks] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What has this example to do with the class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good, found one more problem though.
doc/classes/AStar.xml
Outdated
astar.AddPoint(1, new Vector3(0, 0, 0)); | ||
astar.AddPoint(2, new Vector3(0, 5, 0)); | ||
astar.ConnectPoints(1, 2); | ||
Vector3 res = astar.getClosestPositionInSegment(new Vector3(3, 3, 0)); // Returns (0, 3, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vector3 res = astar.getClosestPositionInSegment(new Vector3(3, 3, 0)); // Returns (0, 3, 0) | |
Vector3 res = astar.GetClosestPositionInSegment(new Vector3(3, 3, 0)); // Returns (0, 3, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
d331fef
to
37a3cf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be good now. The CI failure is unrelated to this PR.
It would need a last rebase so that we can get CI to pass (the error is on the master commit this PR is currently based on). |
37a3cf4
to
584fc2b
Compare
rebased |
Only existing GDScript code examples are converted and added to the docs. This is the first batch include classes beginning with A and B. Included classes: * AcceptDialog * AESContext * Animation * AnimationNodeStateMachine * AnimationNodeStateMachinePlayback * AnimationNodeStateMachineTransition * Array * ArrayMesh * AStar * AStar2D * Bool * Button
584fc2b
to
c5aded5
Compare
Thanks a ton! |
var array1 = new Godot.Collections.Array("One", 2); | ||
var array2 = new Godot.Collections.Array(3, "Four"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neikeq pointed out that we can also use {
and }
, which may be preferred...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I switched to that syntax in later PRs
var array = new Godot.Collections.Array{2, 4, 6, 8}; | ||
if (array.Contains(2)) | ||
{ | ||
GD.Print("Containes!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo, Containes
-> Contains
Includes: * Variant * Viewport and two fixes in Array that were pointed out in godotengine#40978 VisualScript classes are skipped on purpose. That is the final commit of the inital code porting to C#. :)
First PR in my code example port effort.
See #40613 for more details.
Since there are a lot classes (and a lot less having examples) I group the changes together, but I don't really know what is practical so ¯\(ツ)/¯
I created this code translation tool to speed up the conversion process.
I left the sort as it is, because I don't know how and if it is done in C#