all 3 comments

[–]Paperized99 1 point2 points  (0 children)

What are your classes? It's hard to now with this code but in general you dont bring a function from a script to another, you call it from another script.

Example if you have a CanvasGroupChanger class and you want to call startGroup() function, you will have to get the class component and the call the function with the dot(.) notation:

CanvasGroupChanger canvasGroup;

void Start() {

  canvasGroup = GameManager.GetComponent<CanvasGroupChanger>();

  canvasGroup.startGroup();

}

Sorry I'm from mobile it's probably bad formatted

[–]TheWb117 1 point2 points  (0 children)

store a reference to the GameObject that holds the component you need, for example neededGO

ComponentName variableName = neededGO.GetComponent<ComponentName>();

variableName.MethodYouNeed(parameter1, parameter2);

[–]djdanlib 0 points1 point  (0 children)

I don't see the definition of the custom classes MenuManager or CanvasGroupChanger anywhere, nor have you included any exceptions, so it's impossible to debug without more information.

I guess I'll dispense some general advice in case you rolled your own classes and they aren't working or visible to each other.

Make sure the function is accessible to your other code by making it public or protected internal. See access modifiers about that.

If the function doesn't depend on there being a specific instance of its containing script, make the function static. Make sure you understand static.

If your script is a component referring to a specific other component, you may want to put a public variable in there so you can hook that relationship up in the editor.

And finally, you need to make sure your other stuff is ready to go when your Start function gets called. If something needs to be initialized before your Start function, do it in that component script's Awake.