You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a long time developer but relatively new to Godot, this would have saved me hours of pain.
Pseudocode example:
Before:
Player.cs (Attached via Godot editor to a KinematicBody2D Node named 'Player'):
public class Player : KinematicBody2D
{
...
// My custom method
public void Attack (Enemy enemy)
{
// Implement my uber-cool attack!
}
}
Combat.cs (Attached via Godot editor to some sibling node):
...
// In some collision method:
var player = GetNode <KinematicBody2D> ("../Player"); // Incorrect: Obtain reference to
// Player class Node instance
// which extends KinematicBody2D
player.Attack (enemy); // Error: Cannot resolve symbol 'Attack'
// Huh? How do I fix this?
// Everything "just works" in GDScript... >:(
...
In the above example, the type KinematicBody2D should be hint-underlined, whereby ALT + Enter should show a context action such as Use actual type, in order to fix broken references to fields and methods after a mis-typed call to Node::GetNode.
Additionally, if practical, add a context action to the broken method call itself, such as Fix reference by using actual type.
After:
Combat.cs (Attached via Godot editor to some sibling node):
...
// In some collision method:
var player = GetNode <Player> ("../Player"); // Correct: Obtain reference to
// Player class Node instance
// which extends KinematicBody2D
player.Attack (enemy); // Error resolved; FINISH HIM!!!
...
The text was updated successfully, but these errors were encountered:
knightofiam
changed the title
C#: Add "Use actual type" context action for generically-typed Node::GetNode calls to resolve custom method calls
C#: Add "Use actual type" context action for generically-typed Node::GetNode calls to resolve broken references
Dec 20, 2020
knightofiam
changed the title
C#: Add "Use actual type" context action for generically-typed Node::GetNode calls to resolve broken references
C#: Add "Use actual type" context action for generically-typed Node::GetNode calls to resolve broken custom references
Dec 20, 2020
@van800 Thank you for requesting this on Discord in response to my issue.
As a long time developer but relatively new to Godot, this would have saved me hours of pain.
Pseudocode example:
Before:
Player.cs (Attached via Godot editor to a KinematicBody2D Node named 'Player')
:Combat.cs (Attached via Godot editor to some sibling node)
:In the above example, the type
KinematicBody2D
should be hint-underlined, wherebyALT + Enter
should show a context action such asUse actual type
, in order to fix broken references to fields and methods after a mis-typed call toNode::GetNode
.Additionally, if practical, add a context action to the broken method call itself, such as
Fix reference by using actual type
.After:
Combat.cs (Attached via Godot editor to some sibling node)
:The text was updated successfully, but these errors were encountered: