Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access C# static methods from GDScript if it's a Tool script #89913

Closed
Hanprogramer opened this issue Mar 26, 2024 · 1 comment
Closed

Comments

@Hanprogramer
Copy link

Tested versions

  • Reproducible in Godot 4.2 C#

System information

Godot v4.2.1.stable.mono - Windows 10.0.22000 - Vulkan (Mobile) - dedicated NVIDIA GeForce RTX 2050 (NVIDIA; 31.0.15.4618) - 13th Gen Intel(R) Core(TM) i5-13420H (12 Threads)

Issue description

This issue was done and merged a long time ago. But there's still issue with it.
#81783

This doesn't work in tools scripts. Both GDScript and C# using tool attribute. Same error: Parse Error: Static function "CreateNewDB()" not found in base "CSharpScript".

C#:

using Godot;

[Tool]
[GlobalClass]
public partial class DBHAutoload : GodotObject
{
    public static void CreateNewDB(string path, string dbName, string namespacename, bool gen_class, string class_name, bool add_default_fields)
    {
        var content = ".. insert content here ...";
        var file = FileAccess.Open(path, FileAccess.ModeFlags.Write);
        file.StoreString(content);
        file.Close();
    }
}

GD:

@tool
extends Control

@export var create_dialog : Window

func _on_dbh_create_dialog_create(path, dbname, namespacename, gen_class, classname, add_defaultfields):
	print("Creating in: "  + path)
	DBHAutoload.CreateNewDB()#.CreateNewDB(path,dbname,namespacename,gen_class,classname, add_defaultfields)

Steps to reproduce

  1. Create a C# script with static methods and add tool attribute to it
  2. Create a GDScript to call that method, also in tool script

Minimal reproduction project (MRP)

CSharpTestBed.zip

@Hanprogramer
Copy link
Author

Confirmed fixed on Godot v4.3.dev5.mono

@AThousandShips AThousandShips added this to the 4.3 milestone Mar 26, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants