安装及环境配置
安装GAMEPOT Unreal SDK后配置环境并关联GAMEPOT仪表盘和游戏,即可使用游戏开发所需的功能。
安装SDK
安装GAMEPOT Unreal SDK后,在Unreal中配置项目的方法如下。
请使用管理员账户登录仪表盘。
依次点击下载SDK > Unreal菜单后点击下载。
Android环境配置
如要使用GAMEPOT Unreal SDK开发基于Android的游戏,需设置所需环境。
设置最低配置
如要设置可安装及运行应用的最低配置,请使用下列代码。
minSdkVersion:API 17以上(Jelly Bean 4.2)
修改GamePot_Android_UPL.xml
如果为设置Android环境修改GamePot_Android_UPL.xml文件,在Unreal打开下载的$S(PluginDir)/GamePot_Android_UPL.xml文件后参考表的内容修改代码的输入值。
不使用
(optional)
值时,请删除相应行。
值
概述
gamepot_project_id
由GAMEPOT发放的项目ID
gamepot_store
商店值(google
、one
或galaxy
)
gamepot_app_title
应用标题(FCM)
gamepot_push_default_channel
已添加的默认渠道名称,请勿修改。
facebook_app_id
从Facebook控制台获取的应用ID
fb_login_protocol_scheme
从Facebook控制台获取的protocol scheme fb[app_id]
gamepot_naver_clientid
从NAVER开发人员控制台获取
gamepot_naver_secretid
从NAVER开发人员控制台获取
gamepot_line_channelid
从LINE开发人员控制台获取
gamepot_twitter_consumerkey
从Twitter开发人员控制台获取
gamepot_twitter_consumersecret
从Twitter开发人员控制台获取
gamepot_elsa_projectid
使用NAVER Cloud ELSA时项目ID
gamepot_region
注意!Game Pod儀表板生成區僅在新加坡輸入sg
gamepot_license_url
注意!僅當遊戲Pods Dashboard生成區域爲日本時,輸入 https://gamepot.apigw.ntruss.com/fw/jp-v1
<buildGradleAdditions>
<insert>
...
android {
...
defaultConfig {
...
resValue "string", "gamepot_project_id", "" // required
resValue "string", "gamepot_store", "google" // required
resValue "string", "gamepot_app_title","@string/app_name" // required (fcm)
resValue "string", "gamepot_push_default_channel","Default" // required (fcm)
resValue "string", "facebook_app_id", "" // optional(Facebook)
resValue "string", "fb_login_protocol_scheme", "" // optional(Facebook)
resValue "string", "gamepot_naver_clientid", "" // optional(从NAVER开发人员控制台获取)
resValue "string", "gamepot_naver_secretid", "" // optional(从NAVER开发人员控制台获取)
resValue "string", "gamepot_line_channelid","" // optional(从LINE开发人员控制台获取)
resValue "string", "gamepot_twitter_consumerkey", "" // optional(从Twitter开发人员控制台获取)
resValue "string", "gamepot_twitter_consumersecret", "" // optional(从Twitter开发人员控制台获取)
resValue "string", "gamepot_elsa_projectid", "" // optional(NAVER Cloud ELSA项目ID)
}
...
}
</insert>
</buildGradleAdditions>
设置推送通知图标
可设置接收推送消息时要显示于通知栏的图标。如果不另行设置,则使用包含在SDK的默认图片,也可自行设置适合游戏的图标。
设置推送通知图标的方法如下。
如下在项目路径下分别创建res/drawable文件夹后,根据各大小添加图片文件。
文件夹名
长度
$S(PluginDir)/ThirdParty/Android/GamePotResources/res/drawable-mdpi/
24x24
$S(PluginDir)/ThirdParty/Android/GamePotResources/res/drawable-hdpi/
36x36
$S(PluginDir)/ThirdParty/Android/GamePotResources/res/drawable-xhdpi/
48x48
$S(PluginDir)/ThirdParty/Android/GamePotResources/res/drawable-xxhdpi/
72x72
$S(PluginDir)/ThirdParty/Android/GamePotResources/res/drawable-xxxhdpi/
96x96
将图片文件名变更为ic_stat_gamepot_small。
iOS环境设置
如要使用GAMEPOT Unreal SDK开发基于的iOS游戏,需设置所需环境。
Buildi版本代碼請以整數形態獨特增加的方式進行。
配置项目
为设置iOS环境,按以下方法配置项目。
将从Google Firebase控制台获取的GoogleService-Info.plist文件添加到Unreal项目中。
请参考表的内容在项目的GamePotConfig-Info.plist文件变更以下设置。
环境变量
概述
gamepot_project_id
由GAMEPOT发放的项目ID
gamepot_facebook_app_id
由Facebook获取的应用ID
gamepot_facebook_display_name
在Facebook上显示的名称
gamepot_google_app_id
GoogleService-Info文件的CLIENT_ID
值
gamepot_google_url_schemes
GoogleService-Info文件的REVERSED_CLIENT_ID
值
gamepot_naver_clientid
NAVER Client ID
gamepot_naver_secretid
NAVER Secret ID
gamepot_naver_urlscheme
NAVER URL Scheme
gamepot_line_channelid
LINE Channel ID
gamepot_line_url_schemes
LINE URL Scheme(line3rdp.{项目绑定ID})
gamepot_twitter_consumerkey
Twitter Consumer Key
gamepot_twitter_consumersecret
Twitter Consumer Secret
gamepot_elsa_projectid
使用NAVER Cloud ELSA时项目ID
gamepot_region
注意!Game Pod儀表板生成區僅在新加坡輸入sg
gamepot_license_url
注意!僅當遊戲Pods Dashboard生成區域爲日本時,輸入 https://gamepot.apigw.ntruss.com/fw/jp-v1
请在项目设置iOS > Extra Plist Data > Additional Plist Data中,按照如下内容添加用户权限获取选项。
使用GAMEPOT客户咨询UI时所需的权限
<key>NSCameraUsageDescription</key> <string>$(PRODUCT_NAME) camera use.</string> <key>NSPhotoLibraryUsageDescription</key> <string>$(PRODUCT_NAME) photo library use.</string> <key>NSMicrophoneUsageDescription</key> <string>$(PRODUCT_NAME) Microphone use.</string>
且为从用户获得IDFA值使用权限请求弹窗的情况
<key>NSUserTrackingUsageDescription</key> <string>$(PRODUCT_NAME) This identifier will collect IDFA for advertising purposes.</string>
将GamePotResources.embeddedframework压缩为.zip后 添加到$S(PluginDir)/ThirdParty/iOS/GamePotResources.embeddedframework.zip的路径并进行构建。
重置
如要执行重置,在开始游戏时加载的第一个场景中使用的对象中添加以下代码。本指南以各示例文件为标准进行说明。
重置示例1 - ASampleGameModeBase.h
#include "GamePotSDKPluginModule.h" //(相应级别使用的)对GAMEPOT API的Callback Event Listener声明 UCLASS() class GAMEPOTSDKSAMPLE_API ASampleGameModeBase : public AGameModeBase { ... void OnLoginSuccess(FNUserInfo NUserInfo); void OnLoginCancel(); void OnLoginFailure(FNError NError); void OnLoginMaintenance(FNAppStatus NAppStatus); void OnLoginNeedUpdate(FNAppStatus NAppStatus); void OnLoginExit(); ... };
重置示例2 - ASampleGameModeBase.cpp
#include "ASampleGameModeBase.h" void ASampleGameModeBase::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage) { AGameModeBase::InitGame(MapName, Options, ErrorMessage); //(在报头声明的Event Listener)绑定至GamePotPluginModule的Callback Event Listener if (FGamePotSDKPluginModule::IsAvailable()) { FGamePotSDKPluginModule::OnSdkLoginSuccess.AddUObject(this, &ASampleGameModeBase::OnLoginSuccess); FGamePotSDKPluginModule::OnSdkLoginCancel.AddUObject(this, &ASampleGameModeBase::OnLoginCancel); FGamePotSDKPluginModule::OnSdkLoginFailure.AddUObject(this, &ASampleGameModeBase::OnLoginFailure); FGamePotSDKPluginModule::OnSdkLoginMaintenance.AddUObject(this, &ASampleGameModeBase::OnLoginMaintenance); FGamePotSDKPluginModule::OnSdkLoginNeedUpdate.AddUObject(this, &ASampleGameModeBase::OnLoginNeedUpdate); FGamePotSDKPluginModule::OnSdkLoginExit.AddUObject(this, &ASampleGameModeBase::OnLoginExit); FGamePotSDKPluginModule::OnSdkLogoutSuccess.AddUObject(this, &ASampleGameModeBase::OnLogoutSuccess); FGamePotSDKPluginModule::OnSdkLogoutFailure.AddUObject(this, &ASampleGameModeBase::OnLogoutFailure); ... } } void ASampleGameModeBase::OnLoginSuccess(FNUserInfo NUserInfo) { // Handling NUserInfo.. } void ASampleGameModeBase::OnLoginCancel() { } void ASampleGameModeBase::OnLoginFailure(FNError NError) { // Handling NError Info.. }
(绑定)Event Listener列表
// 登录成功 FOnSdkLoginSuccess OnSdkLoginSuccess(FNUserInfo NUserInfo); // 取消登录 FOnSdkLoginCancel OnSdkLoginCancel(); // 登录失败 FOnSdkLoginFailure OnSdkLoginFailure(FNError NError); // 登录(维护) FOnSdkLoginMaintenance OnSdkLoginMaintenance(FNAppStatus NAppStatus); // 登录(更新) FOnSdkLoginNeedUpdate OnSdkLoginNeedUpdate(FNAppStatus NAppStatus); // 关闭登录UI(使用showLoginWithUI时) FOnSdkLoginExit OnSdkLoginExit(); // (维护、更新时)应用结束 FOnSdkAppClose OnSdkAppClose(); // 退出登录成功 FOnSdkLogoutSuccess OnSdkLogoutSuccess(); // 退出登录失败 FOnSdkLogoutFailure OnSdkLogoutFailure(FNError NError); // showWebview关闭 FOnWebviewClose OnSdkWebviewClose(FString msg); // 购买成功 FOnSdkPurchaseSuccess OnSdkPurchaseSuccess(FNPurchaseInfo NPurchaseInfo); // 取消购买 FOnSdkPurchaseCancel OnSdkPurchaseCancel(); // 购买失败 FOnSdkPurchaseFailure OnSdkPurchaseFailure(FNError NError); // getPurchaseDetailListAsync成功 FOnSdkPurchaseDetailListSuccess OnSdkPurchaseDetailListSuccess(TArray<FNPurchaseItem> Items); // getPurchaseDetailListAsync失败 FOnSdkPurchaseDetailListFailure OnSdkPurchaseDetailListFailure(FNError NError); // createLinking成功 FOnSdkCreateLinkingSuccess OnSdkCreateLinkingSuccess(FNUserInfo NUserInfo); // 取消createLinking FOnSdkCreateLinkingCancel OnSdkCreateLinkingCancel(); // createLinking失败 FOnSdkCreateLinkingFailure OnSdkCreateLinkingFailure(FNError NError); // deleteLinking成功 FOnSdkDeleteLinkingSuccess OnSdkDeleteLinkingSuccess(); // deleteLinking失败 FOnSdkDeleteLinkingFailure OnSdkDeleteLinkingFailure(FNError NError); // 公告事项图片(showNotice、showEvent)点击操作后回调scheme FOnSdkReceiveScheme OnSdkReceiveScheme(FString scheme); // deleteMember成功 FOnSdkDeleteMemberSuccess OnSdkDeleteMemberSuccess(); // deleteMember失败 FOnSdkDeleteMemberFailure OnSdkDeleteMemberFailure(FNError NError); // 优惠券(使用)成功 FOnSdkCouponSuccess OnSdkCouponSuccess(FString msg); // 优惠券(使用)失败 FOnSdkCouponFailure OnSdkCouponFailure(FNError NError); // showAgreeDialog(是否同意条款)更新成功 FOnAgreeDialogSuccess OnSdkAgreeDialogSuccess(FNAgreeResultInfo NAgreeResultInfo); // showAgreeDialog(是否同意条款)更新失败 FOnAgreeDialogFailure OnSdkAgreeDialogFailure(FNError NError); // setPush成功 FOnPushSuccess OnSdkPushSuccess(); // setPushAdStatus成功 FOnPushAdSuccess OnSdkPushAdSuccess(); // setPushNightStatus成功 FOnPushNightSuccess OnSdkPushNightSuccess(); // setPushStatus成功 FOnPushStatusSuccess OnSdkPushStatusSuccess(); // setPush失败 FOnPushFailure OnSdkPushFailure(FNError NError); // setPushAdStatus失败 FOnPushAdFailure OnSdkPushAdFailure(FNError NError); // setPushNightStatus失败 FOnPushNightFailure OnSdkPushNightFailure(FNError NError); // setPushStatus失败 FOnPushStatusFailure OnSdkPushStatusFailure(FNError NError);
设置错误代码
如要设置错误代码,请使用下列代码。
USTRUCT()
struct FNError
{
//Detail Error code
static const int CODE_UNKNOWN_ERROR = 0; // 未知错误
static const int CODE_NOT_INITALIZE = 1; // 初始化失败
static const int CODE_INVAILD_PARAM = 2; // 参数不正确时
static const int CODE_MEMBERID_IS_EMPTY = 3; // 没有组成人员ID数据的情况
static const int CODE_NOT_SIGNIN = 4; // 未登录的状态
static const int CODE_NETWORK_MODULE_NOT_INIT = 3000; // 网络模块未重置的情况
static const int CODE_NETWORK_ERROR = 3001; // 发生网络连接错误及超时时
static const int CODE_SERVER_ERROR = 4000; // 在server-side发生的错误
static const int CODE_SERVER_HTTP_ERROR = 4001; // http response code不成功时
static const int CODE_SERVER_NETWORK_ERROR = 4002; // 发生网络连接错误及超时时
static const int CODE_SERVER_PARSING_ERROR = 4003; // 解析从服务器接收的数据时发生错误
static const int CODE_CHARGE_UNKNOWN_ERROR = 5000; // 支付时发生未知错误并由商店传递错误的情况
static const int CODE_CHARGE_PRODUCTID_EMPTY = 5001; // 未输入product id的情况
static const int CODE_CHARGE_PRODUCTID_WRONG = 5002; // product id输入错误时
static const int CODE_CHARGE_CONSUME_ERROR = 5003; // consume出错
UPROPERTY()
int code; // error Code
UPROPERTY()
FString message; // error Message
}
Last updated