In C# how to access function from another script?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ondesic

Currently I have 2 scripts. Main.cs and Test.cs.
In the Main.cs there is a function:
I want to call that function from the Test.cs.

The Node setup is:

Main (has Main.cs which contains the ShowInput() function)
----------Button (has Test.cs)

From the Test.cs script, I am accessing the ShowInput() function like this:


This works, but it very tedious. Is there a better way?

:bust_in_silhouette: Reply From: dphe
(GetNode("/Main") as Main).ShowInput();

or make Main Singleton?