After adding C#, project doesn't respond

Godot Version

4.2.1

Question

Hopefully this is a simple fix, but it’s the second time I’ve “locked up” a project after fiddling with C# inclusions.

The unresponsiveness involves any script it seems, as even GDScript is not running. Setting a breakpoint in Godot on the first line within func _ready() -> void: doesn’t stop at the breakpoint. The game window opens and renders initial things, but executes none of the scripting.

I had been instantiating the C# with var helper = preload("res://helper.cs") within a function and that was working and allowing property hinting of the object’s members.

However, after doing one of the below attempts at instantiating at a higher level for more accessibility, the unresponsiveness began (apologies for possible errors, I’m trying to recall these from memory since I had changed some things back in an attempt to restore function):

  • Added a Node to the scene and attached the C# script to it. In the main GDScript I tried to make a property with @onready var helper = $helper so I could call its members from within that script.
  • Tried to instantiate it as a member property with @onready var helper = preload("res://helper.cs").

What should I try to change to restore script execution? What should I be avoiding with C# scripts to prevent this headache?

Okay, maybe I simply made a silly mistake. After looking at the main scene file, the C# script was attached to the root node of it, rather than main.gd. I was pretty sure I’d attached the C# to the child node, but a misclick could certainly have caused this.

It’s working again after reattaching main.gd. Is it customary to close threads that end up like this?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.