godot: Mono: AutoLoad inheriting Node still gives error: Script does not inherit a Node
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Godot version: 3.2 stable mono OS/device including version: Debian 10 Issue description:
E 0:00:00.662 start: Script does not inherit a Node: res://AutoLoad/GodotUtilities.cs
<C++ Error> Condition "!valid_type" is true. Continuing.
<C++ Source> main/main.cpp:1693 @ start()
E 0:00:00.666 start: Script does not inherit a Node: res://AutoLoad/Pool.cs
<C++ Error> Condition "!valid_type" is true. Continuing.
<C++ Source> main/main.cpp:1693 @ start()
Steps to reproduce:
namespace GodotUtilities
{
public class Log : Node
{
public class Pool<T> : Node where T : new()
{
Minimal reproduction project: NA
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 9
- Comments: 49 (7 by maintainers)
Script does not inherit from Node
error is still present on v4.1.stable.mono.official [970459615]Steps to reproduce:
Test.cs
with this codeTest.cs
and click Add buttonMore errors: Closing “Project Settings” window and opening it again will print this error:
And more errors: Clicking trash bin icon to remove
Test.cs
autoload will print this error:There seems to be some confusion in this issue with unrelated reports, with some being bugs, some being misunderstandings.
This bug report is about C# scripts that inherit Node and are being used as an AutoLoad, and apparently the engine still complains that they don’t inherit Node. That’s a bug that needs to be fixed (if it’s still reproducible).
For GDScript users who write scripts that do not inherit Node (e.g. inherit Reference or Object), and get the error that the script does not inherit Node… well the error tells you the problem. Your AutoLoad needs to inherit Node, as it’s added as a Node to the scene tree.
Godot version: Godot_v3.2.3-stable_win64.exe
OS/device including version: Win 10 Pro
Issue Description: Autoload of gd-script raises error when not inheriting Node (or subclass of Node)
Steps to reproduce:
Minimal project example: godot_test_issue36787.zip
I’ve run into this problem before. The error occurs when the Godot file name (e.g. my_class.cs) and the C# class name (e.g. MyClass) do not match. This is a catch-22 since the Godot standard for file naming is all lower case while C# class names are CamelCase. The solution is to assure the .cs file name exactly matches the C# class name.
I had this happen when my C# class name did not match the
*.cs
file name. Renaming the class fixed the error.Edit: This issue showed up when exporting on Win10, but not when running in the editor. Making tscn files and changing the autload config solved it for the export. I also had capitalization mismatches in the paths of resources between loading things in the code, and referencing scenes in tscn files that needed to be resolved
Generating a new sln from the
Tools
menu fixed the issue for me, on that sample project 😕Don’t know if this will help. I just ran into this error on a newly started project. The problem was caused by the C# Class name not matching the script file name.
For example, I created a new C# script inherited from Node and named the script file sentinel_file.cs. The C# generated code named the class SentinelFile (which is exactly what I wanted). However, the “does not inherit a Node” error resulted.
Changing the class name in the C# script to “sentinel_file” resolved the problem.
This also happened to me in 3.4 stable, I restarted the editor and it no longer shows me the error.
As the top of the issue states, no need to confirm this further, especially as people have just recently done the same
I am new to Godot.
I am able to reproduce the issue on v4.0 .Net by just opening a community sample project “Godot .NET thirdperson controller”
Hey, sorry, I’m using 3.5.
I found that it happens only when adding autoload script before build. According to the implementation, I assume that at the moment of this check
App doesn’t have this class in hashmap for some reason, so it fails.
4.0 alpha is cool, but not ready for C# yet
In my case, all of my autoloads classes match the filenames. The error still happens. Also tried to make them partials, that didn’t work either.
(Linux user) Switching Build Tool to DotNet CLI solved my issue.
I had this error before because I renamed my project. I made this error go away by making sure the root project folder was the same name as the .csproj / .sln filenames. And I made sure to rename the project name in .sln and in project.godot files.
Godot was complaining that all the scripts in my autoload were not inheirted by nodes when they were. And when I removed all autoloads Godot started complaining about the same errors in every non-autoload script.
Can confirm this issue on Ubuntu 20.10 / Godot 3.2.3 and 3.2.2. Is there a workaround? This seems to make C# / Mono completely unusable.
Got this error after updating to 3.2.3. Godot version: 3.2.3 stable mono OS/device including version: Ubuntu 20.04.2 LTS Mono version: Mono JIT compiler version 6.8.0.105 Issue description: E 0:00:02.252 start: Script does not inherit a Node: res://script/Global.cs <C++ Error> Condition “!valid_type” is true. Continuing. <C++ Source> main/main.cpp:1766 @ start()