This is a share module for Godot Game Engine (2 & 3) for Android & iOS. You'll be able to share text and/or images in your apps.
To use this module you'll need a custom template for Android. You can build it by yourself or download a precompiled one.
Another option available for Godot 3.2+ is the new Android plugin system, much easier to use (no recompilation needed). You can find a port of this module using this system here.
This is harder, but you'll have more control over the building process. You can, for example, include any other module you want. For that, do the following steps:
- Clone or download this repository.
- Clone or download the Godot Engine repository. One important note here is that this must match the same version of the Godot editor you're using to develop your game.
- Drop the "share" directory inside the "modules" directory on the Godot source.
- Recompile the android export template following the official instructions.
If you don't want or can't build the template by yourself, you can find a precompiled template with this module here. Go to the release tab and download the zip file.
-
In your project goto Export > Target > Android:
- Options:
- Custom Package:
- place the template apk you had compiled (or downloaded)
- Custom Package:
- Options:
-
open (Project)/android/build/gradle.properties file and add the following line
android.useAndroidX=true
android.enableJetifier=true
- Add the following lines to
project.godot
file (Godot 3) orengine.cfg
(Godot 2):
[android]
modules="org/godotengine/godot/GodotShare"
If you have more separate by comma.
- Drop the "share" directory inside the "modules" directory on the Godot source;
- Recompile the iOS export template following the official instructions.
- For exporting, follow the exporting to iOS official documentation.
Just make sure you're using your custom template (compiled in the previous step), for that rename it to "godot_opt.iphone" and replace the file with same name inside the Xcode project.
- Export your project from Godot, it'll create an Xcode project;
- Copy the library (.a) you have compiled following the official documentation inside the exported Xcode project. You must override the 'your_project_name.a' file with this file.
Was this project useful for you? Wanna make a donation? These are the options:
If you don't have any money, but still willing to help me you can install Brave browser using my referral link. If you do so and keep using the browser, I'll receive some reward.
If you're already a Brave user, please consider donating some BATs ;)
The following methods are available:
# Share text
# @param String title
# @param String subject
# @param String text
shareText(title, subject, text)
# Share image
# @param String image_abs_path The image location absolute path
# @param String title
# @param String subject
# @param String text
void sharePic(image_abs_path, title, subject, text)
An important note is that the image you want to share must be saved on the "user://"
virtual directory root to be accessible, you can use OS.get_user_data_dir()
to get its absolute path (required by sharePic
).
In the demo directory you'll find a working sample project for Godot 2 and 3 where a screen capture is shared.
The screen capture isn't working for the Godot 3 project, it's a known issue for mobile platforms and you can see more details here.