diff options
author | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-08-17 14:23:04 -0700 |
---|---|---|
committer | Fredia Huya-Kouadio <fhuya@meta.com> | 2023-08-17 14:35:56 -0700 |
commit | f42745b1d88e7ad563f1fd9668c04ed8b261189b (patch) | |
tree | 98032a8f560ec51d0a5a8cd58f820d0df02eda17 /plugins/hello_world/src | |
parent | 49ef8e3d93b335967361640e77c97a220e4339f3 (diff) | |
download | godot-android-samples-f42745b1d88e7ad563f1fd9668c04ed8b261189b.tar.gz godot-android-samples-f42745b1d88e7ad563f1fd9668c04ed8b261189b.tar.bz2 godot-android-samples-f42745b1d88e7ad563f1fd9668c04ed8b261189b.zip |
Update the 'Hello World' plugin sample to match updates to the addon's folder structure
Diffstat (limited to 'plugins/hello_world/src')
8 files changed, 64 insertions, 4 deletions
diff --git a/plugins/hello_world/src/main/AndroidManifest.xml b/plugins/hello_world/src/main/AndroidManifest.xml index 8bb5fa4..ef98274 100644 --- a/plugins/hello_world/src/main/AndroidManifest.xml +++ b/plugins/hello_world/src/main/AndroidManifest.xml @@ -1,11 +1,10 @@ -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="fhuyakou.godot.plugin.android.helloworld"> +<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application> <!-- Plugin metadata: - - In the `android:name` attribute, the `org.godotengine.plugin.v1` prefix + - In the `android:name` attribute, the `org.godotengine.plugin.v2` prefix is required so Godot can recognize the project as a valid Godot Android plugin. The plugin name following the prefix should match the value of the plugin name returned by the plugin initializer. @@ -14,7 +13,7 @@ initializer. --> <meta-data - android:name="org.godotengine.plugin.v1.HelloWorld" + android:name="org.godotengine.plugin.v2.HelloWorld" android:value="fhuyakou.godot.plugin.android.helloworld.HelloWorldPlugin" /> </application> </manifest> diff --git a/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gdignore b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gdignore new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gdignore @@ -0,0 +1 @@ + diff --git a/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gitignore b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gitignore new file mode 100644 index 0000000..375ed0d --- /dev/null +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.bin/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!.gdignore diff --git a/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/.gdignore b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/.gdignore new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/.gdignore diff --git a/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/hello_world_editor_export_plugin.gd b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/hello_world_editor_export_plugin.gd new file mode 100644 index 0000000..8137718 --- /dev/null +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/hello_world_editor_export_plugin.gd @@ -0,0 +1,16 @@ +@tool +extends EditorExportPlugin + +func _supports_platform(platform): + if platform is EditorExportPlatformAndroid: + return true + return false + +func _get_android_libraries(platform, debug): + if debug: + return PackedStringArray(["hello_world_plugin/.bin/debug/HelloWorld.debug.aar"]) + else: + return PackedStringArray(["hello_world_plugin/.bin/release/HelloWorld.release.aar"]) + +func _get_name(): + return "HelloWorldPlugin" diff --git a/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/hello_world_editor_plugin.gd b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/hello_world_editor_plugin.gd new file mode 100644 index 0000000..85be8ad --- /dev/null +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/.export/hello_world_editor_plugin.gd @@ -0,0 +1,16 @@ +@tool +extends EditorPlugin + +# A class member to hold the export plugin during its lifecycle. +var export_plugin : EditorExportPlugin + +func _enter_tree(): + # Initialization of the plugin goes here. + export_plugin = preload("hello_world_editor_export_plugin.gd").new() + add_export_plugin(export_plugin) + + +func _exit_tree(): + # Clean-up of the plugin goes here. + remove_export_plugin(export_plugin) + export_plugin = null diff --git a/plugins/hello_world/src/main/assets/addons/hello_world_plugin/interface/hello_world_plugin.gd b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/interface/hello_world_plugin.gd new file mode 100644 index 0000000..ed84ef3 --- /dev/null +++ b/plugins/hello_world/src/main/assets/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/plugins/hello_world/src/main/assets/addons/hello_world_plugin/plugin.cfg b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/plugin.cfg new file mode 100644 index 0000000..9428d75 --- /dev/null +++ b/plugins/hello_world/src/main/assets/addons/hello_world_plugin/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="HelloWorldPlugin" +description="Sample to showcase how to package a Godot Android plugin " +author="Fredia Huya-Kouadio (m4gr3d)" +version="" +script=".export/hello_world_editor_plugin.gd" |