The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

I have a game for android which i was creating using only GDscript .
When i heard that Godot 3.2 Mono supporting Android Export , i moved the project to Godot 3.2 Mono actually rc2 .

In my game i have defined a Gdscript global_variables.gd as a Singleton that contain shared variables across all my game .

MY QUESTION IS : is there is a way or How can i use and get data from this file in a C# script file class ?

in Engine by (32 points)

1 Answer

+2 votes
Best answer
public class Globals : Node
{
    private Node Globals;

    public override void _Ready()
    {
        Globals = GetNode("/root/global_variables");
        GD.Print(Globals.Get("player_score"));
    }

}

this is a example of how to get player_score stored in global_variables.gd

there are other methods to get functions and set variables values like Globals.Call("function_name",properties); and Globals.Set("variable_name", value);

by (32 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.