Skip to content

Shin-NiL/Godot-Share

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GodotShare

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.

Image Sharing Screenshot

How to use

Android

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.

Compiling the template (First Option)

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.

Using precompiled templates (Second Option)

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.

Project configuration

  • In your project goto Export > Target > Android:

    • Options:
      • Custom Package:
        • place the template apk you had compiled (or downloaded)
  • 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) or engine.cfg (Godot 2):
	[android]
	modules="org/godotengine/godot/GodotShare"

If you have more separate by comma.

iOS

Godot 2

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.

Godot 3

  • 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.

Donations

Was this project useful for you? Wanna make a donation? These are the options:

Paypal

My Paypal donation link

Brave browser

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 ;)

API Reference (Android & iOS)

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)

Usage

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.

Known Issues

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.