Godot QR Plugin
Godot plugin that provides a unified GDScript interface for generating and scanning QR codes on Android and iOS using native platform implementations.
The plugin supports:
- Generating QR code images and textures
- Scanning QR codes from images
- Receiving scan results and errors via signals
Key Features:
- Unified GDScript API for Android & iOS
- Generate QR codes as Image or ImageTexture
- Custom foreground and background colors
- Scan QR codes from Image data
- Signal-based scan results and error handling
- Native platform performance
Table of Contents
- Demo
- Installation
- Usage
- Signals
- Methods
- Classes
- Platform-Specific Notes
- Links
- All Plugins
- Credits
- Contributing
Demo
Try the demo app located in the demo directory.
Installation
_Before installing this plugin, make sure to uninstall any previous versions of the same plugin._
_If installing both Android and iOS versions of the plugin in the same project, then make sure that both versions use the same addon interface version._
There are 2 ways to install the QR plugin into your project:
- Through the Godot Editor's AssetLib
- Manually by downloading archives from Github
Installing via AssetLib
Steps:
- search for and select the
QRplugin in Godot Editor - click
Downloadbutton - on the installation dialog...
- keep
Change Install Foldersetting pointing to your project's root directory - keep
Ignore asset rootcheckbox checked - click
Installbutton
- keep
- enable the plugin via the
Pluginstab ofProject->Project Settings...menu, in the Godot Editor
When installing via AssetLib, the installer may display a warning that states "_[x number of]_ files conflict with your project and won't be installed." You can ignore this warning since both versions use the same addon code.
Installing manually
Steps:
- download release archive from Github
- unzip the release archive
- copy to your Godot project's root directory
- enable the plugin via the
Pluginstab ofProject->Project Settings...menu, in the Godot Editor
Usage
Add QR node to your main scene or register it as an AutoLoad singleton.
Generating a QR Code:
@onready var qr := $QR
func _ready():
var img := qr.generate_qr_image(
"https://godotengine.org",
512,
Color.BLACK,
Color.WHITE
)
$TextureRect.texture = ImageTexture.create_from_image(img)
Generating a Texture directly:
var texture := qr.generate_qr_texture("Hello from Godot!")
$Sprite2D.texture = texture
Scanning a QR Code from an Image:
@onready var qr := $QR
func _ready():
qr.qr_detected.connect(_on_qr_qr_detected)
qr.qr_scan_failed.connect(_on_qr_qr_scan_failed)
qr.scan_qr_image(my_image)
func _on_qr_qr_detected(data: String) -> void:
print("QR detected: %s" % data)
func _on_qr_qr_scan_failed(error: ScanError) -> void:
print("QR scan failed due to '%s'" % error.get_description())
Scanning live camera feed
Combine the QR Plugin with the Native Camera Plugin to scan QR codes directly from your device’s live camera feed. See the demo app for a working example.
Signals
qr_detected(data: String)- Emitted when a QR code has been successfully scanned along with the scanned dataqr_scan_failed(error: ScanError)- Emitted when scanning a QR code has failed
Methods
generate_qr_image(uri, size, foreground, background) -> Image- Generates a QR code as a Godot Image.
uri: String– Data to encodesize: int– Output image size in pixels (default: 512)foreground: Color– QR foreground colorbackground: Color– QR background color
generate_qr_texture(uri, size, foreground, background) -> ImageTexture- Same as
generate_qr_image(), but returns an ImageTexture.
- Same as
scan_qr_image(image: Image) -> void- Scans a QR code from a Godot Image.
- Results are returned asynchronously via signals.
Classes
This section documents the GDScript interface classes implemented and exposed by the plugin.
ImageInfo
Internal data wrapper used for transferring image data between Godot and native code.
Properties (internal):
buffer: PackedByteArraywidth: intheight: intformat: Image.Formathas_mipmaps: bool
ScanError
Encapsulates QR scanning errors.
Error Codes:
NONEINVALID_IMAGENO_CODE_DETECTEDSCANNER_FAILUREINTERNAL_ERROR
Methods:
get_code() -> ScanError.Codeget_description() -> String
Platform-Specific Notes
Android
- Download Android export template and enable gradle build from export settings
- Troubleshooting:
- Logs:
adb logcat | grep 'godot'(Linux),adb.exe logcat | select-string "godot"(Windows) - You may find the following resources helpful:
- https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_android.html
- https://developer.android.com/tools/adb
- https://developer.android.com/studio/debug
- https://developer.android.com/courses
iOS
- Follow instructions on Exporting for iOS
- View XCode logs while running the game for troubleshooting.
- See Godot iOS Export Troubleshooting.
Links
All Plugins
| Plugin | Android | iOS | Free | Open Source | License |
|---|---|---|---|---|---|
| Admob | ✅ | ✅ | ✅ | ✅ | MIT |
| Notification Scheduler | ✅ | ✅ | ✅ | ✅ | MIT |
| Deeplink | ✅ | ✅ | ✅ | ✅ | MIT |
| Share | ✅ | ✅ | ✅ | ✅ | MIT |
| In-App Review | ✅ | ✅ | ✅ | ✅ | MIT |
| Native Camera | ✅ | ✅ | ✅ | ✅ | MIT |
| Connection State | ✅ | ✅ | ✅ | ✅ | MIT |
| OAuth 2.0 | ✅ | ✅ | ✅ | ✅ | MIT |
| QR | ✅ | ✅ | ✅ | ✅ | MIT |
| Firebase | ✅ | ✅ | ✅ | ✅ | MIT |
Credits
Developed by Cengiz
Based on Godot Mobile Plugin Template
Original repository: Godot QR Plugin
Contributing
See our guide if you would like to contribute to this project.
Changelog for version v1.1-Multi
No changelog provided for this version.