godot icon indicating copy to clipboard operation
godot copied to clipboard

Mono: AutoLoad inheriting Node still gives error: Script does not inherit a Node

Open git2013vb opened this issue 4 years ago • 49 comments


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

git2013vb avatar Mar 04 '20 11:03 git2013vb

Godot version: Git Mono (Branch: 3.2 Commit: eec14d4323fea0ea280c3a2e6644e4c1ca776b0d)

OS/device including version: 5.4.24-1-MANJARO (Arch Linux Derivative)

Issue Descriptions: Ran into, what I assume to be, the same issue with Autoload.

In my case, the bug occurs if the AssemblyName value in the csproj file was changed from its default value. I was modifying this because I was attempting to structure my project into multiple assemblies. However, I haven't tested this yet, but I wonder if it could be triggered inadvertently if the Generate Project option is disabled and the project is renamed.

Steps to reproduce:

  1. Create a new project
  2. Add a cs source file
  3. Add cs source file to autoload
  4. Run, confirm that the script is loaded without issue.
  5. Disable project generation
  6. Open the .csproj file
  7. Modify the AssemblyName tag to something else.
  8. Save and Run, note that it fails to load the script with the "Script does not inherit a Node" error, on the '!valid_type' condition.

Minimal reproduction project: New Game Project.zip

notverymoe avatar Mar 21 '20 04:03 notverymoe

@git2013vb @Draghi Can you (or anyone else) still reproduce this bug in Godot 3.2.3 or any later release? It uses a new .csproj format. Make sure to back up your projects before upgrading!

If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop.

Calinou avatar Oct 05 '20 19:10 Calinou

I get the same error on Godot 3.2.3 for a .gd script that extends Object instead of Node (also if it extends nothing).

E 0:00:00.937   start: Script does not inherit a Node: res://data/DataArray2D.gd
  <C++ Error>   Condition "!valid_type" is true. Continuing.
  <C++ Source>  main/main.cpp:1766 @ start()

ascripter avatar Dec 23 '20 11:12 ascripter

Got this error too on my project after updating to 3.2.3.

christoffersch avatar Dec 25 '20 22:12 christoffersch

@ascripter @christoffersch Please upload a minimal reproduction project to make this easier to troubleshoot.

Calinou avatar Dec 26 '20 01:12 Calinou

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)

E 0:00:00.741   start: Script does not inherit a Node: res://new_script.gd
  <C++ Error>   Condition "!valid_type" is true. Continuing.
  <C++ Source>  main/main.cpp:1766 @ start()

Steps to reproduce:

  1. Create a new project
  2. Start with Node2D and save scene
  3. Add a gd source file that extends Object
  4. Add this script to Autoload
  5. Run (and set the saved scene as main scene)

Minimal project example: godot_test_issue36787.zip

ascripter avatar Dec 26 '20 11:12 ascripter

In windows, I don't have any probleme with .Cs autoload file. In my gitlab image, it fails with the error above.

evan-boissonnot avatar Feb 22 '21 13:02 evan-boissonnot

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()

inthelamp avatar Feb 23 '21 01:02 inthelamp

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.

ZackingIt avatar Mar 24 '21 21:03 ZackingIt

Ubuntu 20.04.2 and Godot 3.2.3 This mono site https://www.mono-project.com/download/stable/ has the Mono package available for the OS.

inthelamp avatar Mar 24 '21 22:03 inthelamp

I get

E 0:00:00.699   start: Script does not inherit a Node: res://Script.cs
  <C++ Error>   Condition "!valid_type" is true. Continuing.
  <C++ Source>  main/main.cpp:1765 @ start()

if I change the project name, more precisely ProjectSettings' application/config/name. I also lose the ability to build the C# code.

If I rename the project back to its original name, this error disappears and C# code works again.

Currently using Godot's github 3.x branch

dpalacio avatar May 17 '21 05:05 dpalacio

For me it was happening even though I didn't rename my project. For some reason turning off export assemblies inside pck in the mono export settings fixed it. But now I get an error(that seemingly doesn't matter) that says 'ERROR: CSharpLanguage::_load_scripts_metadata: Missing scripts metadata file.'. Mind you this only happens when exporting running in editor works just fine

Vixeliz avatar Jun 06 '21 08:06 Vixeliz

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

JarLowrey avatar Jun 22 '21 02:06 JarLowrey

Just to mention a workaround from https://github.com/godotengine/godot/issues/24949#issuecomment-467017255 that helps when getting this error with plugins: -First build the project (Build button on the top right of the editor) -Then go to Project Settings > Plugins and enable the plugin again

pouleyKetchoupp avatar Jun 22 '21 22:06 pouleyKetchoupp

I solved this problem by building my C# codes with dotnet CLI option in Godot's Editor Settings. In Godot's Editor -> Editor Settings menu: Set Mono -> Builds -> Build Tool to dotnet CLI. I added a C# project file and a solution file of VS Code to use the Build Solution of MSBuild tab provided by Godot.

Ubuntu 20.04.3 LTS .NET SDK 5.0 Godot game engine v3.3

inthelamp avatar Sep 15 '21 15:09 inthelamp

Having same problem with autoload. Difference is in editor build works fine but exporting to android shows this error.

Godot 3.3.3 stable mono Linux

autofool avatar Sep 21 '21 22:09 autofool

Above mentioned workaround didn't work but creating script from Godot editor worked. I removed the script from project folder. Then inside Godot editor go to Script tab. There created new script with same name with File > New script. Then copied the content of old script. After that I didn't see that error.

autofool avatar Sep 22 '21 07:09 autofool

In my case I had forgotten to place one of the libraries I am using with the exported exe, and the two scripts that used it were printing this error message. (Was no printed error message about the library for some reason, showed up in the mono logs though.)

Goblinth avatar Oct 20 '21 16:10 Goblinth

This also happened to me in 3.4 stable, I restarted the editor and it no longer shows me the error.

Torguen avatar Nov 14 '21 18:11 Torguen

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.

tx350z avatar Dec 03 '21 12:12 tx350z

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.

valkyrienyanko avatar Jan 12 '22 01:01 valkyrienyanko

If it helps track it, I'm getting this on a Mac without Mono with GD 3.4.2. It's complaining that an autoloaded script that "extends reference" doesn't inherit a node. (It's some utility functions I use in other scripts.) The program runs fine in spite of the error, possibly because I preloaded it, so it continues to work without autoload or errors.

E 0:00:00.234   start: Script does not inherit a Node: res://common_library.gd
  <C++ Error>   Condition "!valid_type" is true. Continuing.
  <C++ Source>  main/main.cpp:1832 @ start()

ghost avatar Feb 01 '22 22:02 ghost

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.

akien-mga avatar Feb 02 '22 10:02 akien-mga

Linux (Mint 20) BuildTool: Mono. Can confirm this issue exists also in GD4 alpha. I just updated all my C# scripts to use the new Transform3D / Node3D and what not and now also all my autoloads fail because of this issue.

sietse85 avatar May 14 '22 19:05 sietse85

Happens in 3.5 Beta 4 as well

eranimo avatar May 17 '22 00:05 eranimo

(Linux user) Switching Build Tool to DotNet CLI solved my issue.

sietse85 avatar May 17 '22 19:05 sietse85

On Windows, using dotnet CLI had no effect. This error seems impossible to reproduce cleanly, might happen for several reasons.

eranimo avatar May 17 '22 22:05 eranimo

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.

tx350z avatar May 18 '22 09:05 tx350z

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.

eranimo avatar May 21 '22 02:05 eranimo

Is there a workaround for this issue? I cannot export to iOS - I tried using regular C# singletons but my project depends on Node type autoload singletons and its lifecycle.

Version: Godot_v3.4.4-stable_mono_osx.universal

What is the magic environemnt and settings to be able to export? I can't believe it is 2 years this issue is up. If exporting the app to iOS is not a priority anymore you should say that in the homepage and remove it from the "Features" section.

ksvslk avatar Jun 24 '22 22:06 ksvslk