Skip to content

Cannot access static members in C# from GDScript #120988

Description

@SasaSuppenknecht

Tested versions

Reproducible in: v4.6.3.stable.mono.official [7d41c59c4], v4.7.stable.mono.official [5b4e0cb]

System information

Godot v4.6.3.stable.mono - Ubuntu 26.04 LTS 26.04 on Wayland - Wayland display driver, Multi-window, 2 monitors - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 970 (nvidia; 580.159.03) - Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz (8 threads) - 14.99 GiB memory

Issue description

Trying to access a static member in a C# file from GDScript results in an "Invalid access to property or key[...]" error. Accessing static members in GDScript from C# seems to work as well as calling static C# functions from GDScript.

Steps to reproduce

Have two scripts:
script1.gd:

extends Node

func _ready() -> void:
	var cs_object = load("res://script2.cs").new() 
	print(cs_object.Num)

script2.cs:

using Godot;
using System;

public partial class Script2 : Node {
	public static int Num = 42;
}

script1.gd should be attached to a Node to run _ready() and then start the Scene.

Minimal reproduction project (MRP)

static-member-access.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions