Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GODOT - C# referencing current node

Tags:

c#

godot

I have specific problem in coding in GODOT(I'm using C#, I'm new to godot). I need to reference current node that has attached script. Let's say - I have 3 buttons and all of them inherits from base class called "menuButton" that has attached script called "menuScript" that includes code for changing text color onHover. And I need to reference current node, so that I can change the color of child label node.

like image 397
Matěj Husák Avatar asked Sep 17 '25 08:09

Matěj Husák


1 Answers

this

Typically, you don't need to do this. Functions and parameters of the node can be accessed without a node reference

  • Child of current node: GetChild(i) (shortened version of this.GetChild(i))
  • Name of current node: GetName() (shortened version of this.GetName())

You may need to use this for other functions that have a node parameter. Most notably: - Connect("signal", this, "MyMethod")

like image 51
nathanfranke Avatar answered Sep 19 '25 21:09

nathanfranke