Godot Version
4.2
Question
I’m migrating from Unity over to Godot. I’m making an Godot-Android plugin to use custom Android services. I’m trying to avoid writing a single class with 500 methods to access all the Android features I need to interact with. It would be ideal to pass a reference to Godot Engine of a Java class and use that reference to call from Godot scripts into Android.
The idea is to organize the methods by class, and have a Godot script that interfaces with the java class. So graphic calls can go to the graphics java object reference, and game-state calls can go to the game-state java object.
Within Unity this can be done by getting a reference to an AndroidJavaObject. That reference then gives access to the Java methods of that class.
Within Godot, making an AndroidPlugin will provide a singleton that gives access to methods defined in the class that extends GodotPlugin with the @UsedByGodot tag. I’m hoping that I could define, getGraphicsClass() in Java that returns a reference to MyGraphics, that within Godot Scripts, I can call into that reference outside of the GodotPlugin singleton.
Again, this is to help organize all the method calls I want.