Unity SDK_SDK安装及环境配置
安装GAMEPOT Unity SDK后配置环境并关联GAMEPOT仪表盘和游戏,即可使用游戏开发所需的功能。
GAMEPOT SDK支持的语言如下所示。
韩语、英语、意大利语、泰语、越南语、日语、中文(简体/繁体)、印尼语、德语、西班牙语、法语运行应用时,将根据设备语言显示SDK内支持的语言,不支持的语言将显示为英语。以IOS为例)
须将要应用的语言添加至XCode > localization。
构建时,版本代码请以整数形式单独增加。
安装SDK
安装GAMEPOT Unity SDK后,在Unity配置项目的方法如下。
请使用管理员账户登录仪表盘。
依次点击下载SDK > Unity菜单后点击下载。
在Unity中依次点击Assets > Import Package > Custom Package...菜单后导入GamePotUnityPlugin-xxxx.unitypackage文件。
Android环境配置
如要使用GAMEPOT Unity SDK开发基于Android的游戏,需设置所需环境。
设置最低配置
如要设置可安装及运行应用的最低配置,请使用下列代码。
minSDK版本:API 19以上(Kitkat)
修改Gradle
如要修改Gradle文件,请参考表的内容在下列代码输入值后,使用该代码变更设置。
使用编辑器打开 ../Assets/Plugin/Android/mainTemplate.gradle文件。 (从Unity 2019.3.X之后的版本开始修改launcherTemplate.gradle文件)
不使用Facebook登录的客户应按如下所示随机设置facebook_app_id / fb_login_protocol_scheme值,或在构建时设置为不包含../Assets/Plugins/Android/libs/gamepot-channel-facebook.aar文件。gamepot_payment值默认为空。
值
描述
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发放的应用ID
facebook_client_token
Facebook控制台 > 应用 > 设置 > 高级设置 > 客户端Token
gamepot_elsa_projectid
使用NAVER Cloud ELSA服务时,输入ELSA项目ID (参考Effective Log Search & Analytics)
gamepot_region
仅在GAMEPOT仪表盘创建区域为新加坡时输入sg
gamepot_license_url
仅在GAMEPOT仪表盘创建区域为日本时输入https://gamepot.apigw.ntruss.com/fw/jp-v1
...
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", "0" // optional (facebook)
resValue "string", "fb_login_protocol_scheme", "fb0" // optional (facebook)
resValue "string", "facebook_client_token", "" // Facebook控制台 > 应用 > 设置 > 高级设置 > 客户端Token optional(facebook)。
// resValue "string", "gamepot_elsa_projectid", "" // optional (ncp elsa)
resValue "string", "gamepot_region", "" // Caution! Only if the gamepot region is Singapore , value as sg
resValue "string", "gamepot_license_url", "" // Caution! Only if the gamepot region is Japan , value as https://gamepot.apigw.ntruss.com/fw/jp-v1
}
...
}
设置推送通知图标
可设置接收推送消息时要显示于通知栏的图标。 如果不另行设置,则使用包含在SDK的默认图片,也可自行设置适合游戏的图标。
若使用Android Asset Studio制作,将自动按文件夹制作图像,非常方便。
设置推送通知图标的方法如下。
按照以下方法在项目路径下分别创建res/drawable文件夹后,请根据各文件夹大小添加图像文件。
文件夹名
长度
/Assets/Plugins/Android/GamePotResources/res/drawable-mdpi/
24x24
/Assets/Plugins/Android/GamePotResources/res/drawable-hdpi/
36x36
/Assets/Plugins/Android/GamePotResources/res/drawable-xhdpi/
48x48
/Assets/Plugins/Android/GamePotResources/res/drawable-xxhdpi/
72x72
/Assets/Plugins/Android/GamePotResources/res/drawable-xxxhdpi/
96x96
自Unity Engine 202x开始应放入GamePotResources.androidlib文件夹,并将相应资源文件夹添加到mainTemplate.gradle。
...
implementation project('GamePotResources.androidlib')
...
请将图像文件名改为ic_stat_gamepot_small。
屏幕方向设置
按游戏设置屏幕方向的方法如下。
在Unity中打开/Assets/Plugin/Android/AndroidManifest.xml文件。
在Main Activity添加下列代码后,根据游戏情况输入
sensorLandscape
或sensorPortrait
作为游戏值。
...
<activity android:screenOrientation="sensorLandscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
...
</intent-filter>
</activity>
...
Android Resolver、Unity Build设置
为使用SDK,如下设置Android Resolver及Unity Build。
Android Resolver 在Unity的Assets > Play Services Resolver > Android Resolver > Settings菜单中选择Use Jetifier。 请取消选择 Enable Resolution On Build / Enable Auto-Resolution / Patch gradle Template.properties 项目。
Unity Build 在Unity依次点击File > Build Settings > Build System菜单后选择Gradle。
iOS环境设置
如要使用GAMEPOT Unity SDK开发基于iOS的游戏,需设置所需环境。
配置项目
为设置iOS环境,按以下方法配置项目。
将从Google Firebase控制台获取的GoogleService-Info.plist文件添加到Unity项目中。
请参考表的内容在项目的GamePotConfig-Info.plist文件变更以下设置。 (若不使用Facebook登录,构建时请确保排除GAMEPOTFacebook.framework。)
环境变量
描述
gamepot_project_id
由GAMEPOT发放的项目ID
gamepot_facebook_app_id
从Facebook控制台获取的应用ID
gamepot_facebook_display_name
在Facebook上显示的名称
gamepot_facebook_client_token
// Facebook控制台 > 应用 > 设置 > 高级设置 > 客户端Token
gamepot_google_app_id
GoogleService-Info文件的CLIENT_ID
值
gamepot_google_url_schemes
GoogleService-Info文件的REVERSED_CLIENT_ID
值
gamepot_elsa_projectid
使用NAVER Cloud ELSA时项目ID
gamepot_region
仅在GAMEPOT仪表盘创建区域为新加坡时输入sg
gamepot_license_url
仅在GAMEPOT仪表盘创建区域为日本时输入https://gamepot.apigw.ntruss.com/fw/jp-v1
选择Target后,在Info > Custom iOS Target Properties菜单添加下列用户权限获取选项。 (Xcode为准)
相应用户权限用于GAMEPOT客服中心的文件上传功能。
NSCameraUsageDescription, NSPhotoLibraryUsageDescription, NSMicrophoneUsageDescription
从iOS 14版本开始,改成了获取IDFA值时必须向用户请求权限才能获取IDFA值。 因此,为了在获取IDFA值时使用向用户请求权限的弹窗,请在Targets >> Info >> Custom iOS Target Properties中添加以下用户权限获取选项。 (必须添加关于收集目的与使用地点的说明。)
NSUserTrackingUsageDescription
<示例> GAMEPOT样本界面 在File > Build Settings菜单添加GamePotSample>Scene>Login、Main后 > 构建时,可查看样本界面。
重置
如要执行重置,在开始游戏时加载的第一个场景中使用的对象中添加以下代码。
using GamePotUnity;
public class GamePotLoginSampleScene : MonoBehaviour {
void Awake() {
GamePot.initPlugin();
}
void Start () {
GamePot.setListener(GamePotInterface.cs继承到的class);
// ex) GamePot.setListener(new GamePotSampleListener());
}
}
ex)
public class GamePotSampleListener : MonoBehaviour , IGamePot {
....
}
设置错误代码
public class NError
{
// 未知错误
public static readonly int CODE_UNKNOWN_ERROR = 0;
// 初始化失败
public static readonly int CODE_NOT_INITALIZE = 1;
// 参数不正确时
public static readonly int CODE_INVAILD_PARAM = 2;
// 没有组成人员ID数据的情况
public static readonly int CODE_MEMBERID_IS_EMPTY = 3;
// 未登录的状态
public static readonly int CODE_NOT_SIGNIN = 4;
// 网络模块未重置的情况
public static readonly int CODE_NETWORK_MODULE_NOT_INIT = 3000;
// 发生网络连接错误及超时时
public static readonly int CODE_NETWORK_ERROR = 3001;
// 在server-side发生的错误
public static readonly int CODE_SERVER_ERROR = 4000;
// http response code不成功时
public static readonly int CODE_SERVER_HTTP_ERROR = 4001;
// 发生网络连接错误及超时时
public static readonly int CODE_SERVER_NETWORK_ERROR = 4002;
// 解析由服务器接收的数据时发生的错误
public static readonly int CODE_SERVER_PARSING_ERROR = 4003;
// 支付时发生未知错误并由商店传递错误的情况
public static readonly int CODE_CHARGE_UNKNOWN_ERROR = 5000;
// 未输入product id时
public static readonly int CODE_CHARGE_PRODUCTID_EMPTY = 5001;
// 输入错误的product id时
public static readonly int CODE_CHARGE_PRODUCTID_WRONG = 5002;
// consume时错误
public static readonly int CODE_CHARGE_CONSUME_ERROR = 5003;
// error Code
public int code { get; set; }
// error Message
public string message { get; set; }
}
Last updated