diff options
author | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-07-05 12:06:39 -0700 |
---|---|---|
committer | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-07-05 12:10:05 -0700 |
commit | 93543c9cc7b9b7b3526fd3eb2a0f6819cc6fee32 (patch) | |
tree | effa5bd70925039ed7f6d4cbc56d5485e6e9a740 /hello_world/demo/addons | |
parent | 01f6b286390e552cd326df00ad16c65e5f5c703b (diff) | |
download | godot-android-samples-93543c9cc7b9b7b3526fd3eb2a0f6819cc6fee32.tar.gz godot-android-samples-93543c9cc7b9b7b3526fd3eb2a0f6819cc6fee32.tar.bz2 godot-android-samples-93543c9cc7b9b7b3526fd3eb2a0f6819cc6fee32.zip |
Update the directory structure for the Android plugin addon
The addon directory now contains two subfolders:
- "addons/<plugin_dir>/export":
- should contain the editor plugin script and the editor export plugin script. as well as any binaries needed for export
- `plugin.cfg` must point to the editor plugin script in this directory
- must contain a `.gdignore` file to exclude this directory from the export process
- "addons/<plugin_dir>/interface":
- optional directory
- can contain helper gdscript files used by the project to interface with the functionality exposed by the plugin
Diffstat (limited to 'hello_world/demo/addons')
8 files changed, 22 insertions, 5 deletions
diff --git a/hello_world/demo/addons/hello_world_plugin/.gdignore b/hello_world/demo/addons/hello_world_plugin/.gdignore deleted file mode 100644 index 8b13789..0000000 --- a/hello_world/demo/addons/hello_world_plugin/.gdignore +++ /dev/null @@ -1 +0,0 @@ - diff --git a/hello_world/demo/addons/hello_world_plugin/export/.gdignore b/hello_world/demo/addons/hello_world_plugin/export/.gdignore new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/hello_world/demo/addons/hello_world_plugin/export/.gdignore diff --git a/hello_world/demo/addons/hello_world_plugin/HelloWorld.debug.aar b/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.debug.aar Binary files differindex ddb9986..4d59e06 100644 --- a/hello_world/demo/addons/hello_world_plugin/HelloWorld.debug.aar +++ b/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.debug.aar diff --git a/hello_world/demo/addons/hello_world_plugin/HelloWorld.release.aar b/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.release.aar Binary files differindex 8277aa5..6b112c5 100644 --- a/hello_world/demo/addons/hello_world_plugin/HelloWorld.release.aar +++ b/hello_world/demo/addons/hello_world_plugin/export/HelloWorld.release.aar diff --git a/hello_world/demo/addons/hello_world_plugin/hello_world_export_plugin.gd b/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_export_plugin.gd index 6749497..46a8a3b 100644 --- a/hello_world/demo/addons/hello_world_plugin/hello_world_export_plugin.gd +++ b/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_export_plugin.gd @@ -8,9 +8,9 @@ func _supports_platform(platform): func _get_android_libraries(platform, debug): if debug: - return PackedStringArray(["hello_world_plugin/HelloWorld.debug.aar"]) + return PackedStringArray(["hello_world_plugin/export/HelloWorld.debug.aar"]) else: - return PackedStringArray(["hello_world_plugin/HelloWorld.release.aar"]) + return PackedStringArray(["hello_world_plugin/export/HelloWorld.release.aar"]) func _get_name(): return "HelloWorldPlugin" diff --git a/hello_world/demo/addons/hello_world_plugin/hello_world_plugin.gd b/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_plugin.gd index 05bb37a..3865634 100644 --- a/hello_world/demo/addons/hello_world_plugin/hello_world_plugin.gd +++ b/hello_world/demo/addons/hello_world_plugin/export/hello_world_editor_plugin.gd @@ -6,7 +6,7 @@ var export_plugin : EditorExportPlugin func _enter_tree(): # Initialization of the plugin goes here. - export_plugin = preload("hello_world_export_plugin.gd").new() + export_plugin = preload("hello_world_editor_export_plugin.gd").new() add_export_plugin(export_plugin) pass diff --git a/hello_world/demo/addons/hello_world_plugin/interface/hello_world_plugin.gd b/hello_world/demo/addons/hello_world_plugin/interface/hello_world_plugin.gd new file mode 100644 index 0000000..ed84ef3 --- /dev/null +++ b/hello_world/demo/addons/hello_world_plugin/interface/hello_world_plugin.gd @@ -0,0 +1,18 @@ +class_name HelloWorldPlugin extends Object + +## Interface used to access the functionality provided by this plugin + +var _hello_world_singleton + +func _init(): + if Engine.has_singleton("HelloWorld"): + _hello_world_singleton = Engine.get_singleton("HelloWorld") + else: + printerr("Initialization error: unable to access the java logic") + +## Toggle between showing and hiding the hello world text +func helloWorld(): + if _hello_world_singleton: + _hello_world_singleton.helloWorld() + else: + printerr("Initialization error") diff --git a/hello_world/demo/addons/hello_world_plugin/plugin.cfg b/hello_world/demo/addons/hello_world_plugin/plugin.cfg index 0024e5f..bc8575e 100644 --- a/hello_world/demo/addons/hello_world_plugin/plugin.cfg +++ b/hello_world/demo/addons/hello_world_plugin/plugin.cfg @@ -4,4 +4,4 @@ name="HelloWorldPlugin" description="Sample to showcase how to package a Godot Android plugin " author="Fredia Huya-Kouadio (m4gr3d)" version="" -script="hello_world_plugin.gd" +script="export/hello_world_editor_plugin.gd" |