mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Add C# code examples to the docs
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
This commit is contained in:
@@ -6,7 +6,8 @@
|
||||
<description>
|
||||
Button is the standard themed button. It can contain text and an icon, and will display them according to the current [Theme].
|
||||
[b]Example of creating a button and assigning an action when pressed by code:[/b]
|
||||
[codeblock]
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
func _ready():
|
||||
var button = Button.new()
|
||||
button.text = "Click me"
|
||||
@@ -15,7 +16,22 @@
|
||||
|
||||
func _button_pressed():
|
||||
print("Hello world!")
|
||||
[/codeblock]
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
public override void _Ready()
|
||||
{
|
||||
var button = new Button();
|
||||
button.Text = "Click me";
|
||||
button.Connect("pressed", this, nameof(ButtonPressed));
|
||||
AddChild(button);
|
||||
}
|
||||
|
||||
private void ButtonPressed()
|
||||
{
|
||||
GD.Print("Hello world!");
|
||||
}
|
||||
[/csharp]
|
||||
[/codeblocks]
|
||||
Buttons (like all Control nodes) can also be created in the editor, but some situations may require creating them from code.
|
||||
See also [BaseButton] which contains common properties and methods associated with this node.
|
||||
</description>
|
||||
|
||||
Reference in New Issue
Block a user