Cài đặt nhanh
Đưa một plugin LeonoPlugins vào game Godot và gọi hàm đầu tiên. Các bước giống nhau cho mọi plugin; bước riêng (key, setting) nằm trong trang của từng plugin.
Yêu cầu
- Godot 4.7 trở lên.
- Android: đã cài Android SDK + export template trong Godot.
- iOS: máy Mac có Xcode để export/ký app.
Cài addon
-
Tải addon
Mỗi file zip có sẵn thư mục
addons/leono_<tên>/kèm thư viện Android đã build: Muốn tự build (hoặc cần thư viện iOS): xem Build. -
Giải nén vào game
Giải nén zip vào thư mục gốc project Godot (nơi có
project.godot), kết quả:res://addons/leono_nativeutils/ ├── plugin.cfg, plugin.gd, native_utils.gd, deps.json ├── leono_nativeutils.gdextension └── bin/ ├── android/leono_nativeutils.aar └── ios/leono_nativeutils.ios.template_{debug,release}.xcframework -
Bật plugin
Project → Project Settings → Plugins → tick plugin. Autoload của plugin (ví dụ
NativeUtils) được thêm tự động. - Cấu hình export Làm theo nền tảng ở mục bên dưới.
Cấu hình export
- Project → Install Android Build Template… (một lần cho mỗi project).
- Project → Export → Android → bật Use Gradle Build.
- Export. Thư viện Google (Play Review, Install Referrer…) và permission được thêm tự động — không cần sửa
AndroidManifest.xml.
Lần export đầu Gradle cần Internet để tải thư viện, các lần sau dùng cache.
- Project → Export → iOS như bình thường.
- Godot tự link GDExtension của plugin; framework hệ thống và key Info.plist do
plugin.gdthêm. - Không cần CocoaPods, không cần sửa project Xcode.
Gọi hàm đầu tiên
Code game chỉ gọi autoload. Ví dụ với NativeUtils:
func _ready() -> void:
var app := NativeUtils.get_app_info()
print("Phiên bản: ", app.version_name)
# Hàm bất đồng bộ dùng await
var ref := await NativeUtils.get_install_referrer()
print("Nguồn cài: ", ref.get("params", {}).get("utm_source", "organic"))
Chạy trong editor
Trong editor và bản PC không có phần native: mọi hàm vẫn chạy và trả giá trị mặc định an toàn (chuỗi rỗng, {}, -1…), hàm async vẫn trả kết quả. Dùng is_native() nếu cần phân biệt.
if not NativeUtils.is_native():
print("Đang chạy trong editor — dữ liệu giả lập")
Dòng lỗi GDExtension trong editor là bình thường
Editor trên Windows/macOS/Linux in No GDExtension library found for current OS ... .gdextension. File đó chỉ chứa thư viện iOS — không ảnh hưởng chạy thử hay export.