godot
godot copied to clipboard
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
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:
- Create a new project
- Add a cs source file
- Add cs source file to autoload
- Run, confirm that the script is loaded without issue.
- Disable project generation
- Open the .csproj file
- Modify the AssemblyName tag to something else.
- 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
@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.
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()
Got this error too on my project after updating to 3.2.3.
@ascripter @christoffersch Please upload a minimal reproduction project to make this easier to troubleshoot.
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:
- Create a new project
- Start with Node2D and save scene
- Add a gd source file that extends Object
- Add this script to Autoload
- Run (and set the saved scene as main scene)
Minimal project example: godot_test_issue36787.zip
In windows, I don't have any probleme with .Cs autoload file. In my gitlab image, it fails with the error above.
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()
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.
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.
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
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
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
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
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
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
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.
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.)
This also happened to me in 3.4 stable, I restarted the editor and it no longer shows me the error.
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.
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.
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()
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.
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.
Happens in 3.5 Beta 4 as well
(Linux user) Switching Build Tool to DotNet CLI solved my issue.
On Windows, using dotnet CLI had no effect. This error seems impossible to reproduce cleanly, might happen for several reasons.
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.
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.
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.