更新日期:2023-01-05QuickSDK-Unity3D
Downloading “QuickSDK For Unity 3D”version SDK pakage from download center on offical web. ImportQuickSDKForUnity.unitypakage file in Unity project ( if it fail to Import, please confirm whether the file is under non-Chinese path), refer to following pic:
call QuickSDK.cs class API, implement callback methods
Note: Adding quicksdk named space(using quicksdk;) at first, obtain QuickSDK class example by QuickSDK.genInstance() method.
1.2.1. Set monitor/set listener(Necessarily)
API:void setListener(QuickSDKListener quickSDKListener )
Example:Calling QuickSDK.getInstance().setListener function, and transferring the parameters to instantiated QuickSDKListener class object. It is convenient to monitor callback that to set setListener function as soon as possible.
Refer to following code to realized callback:
public class EventHandle : QuickSDKListener { void Start () { QuickSDK.getInstance().setListener (this); } public override void onInitSuccess(){ // initialize success callback } public override void onInitFailed(ErrorMsg errMsg){ // initialize fail callback } public override void onLoginSuccess (UserInfo userInfo){ // login success callback } public override void onLoginFailed (ErrorMsg errMsg){ // login fail callback // if there’s no login button in game,you shall call login API again here. } public override void onSwitchAccountSuccess (UserInfo userInfo){ // switch account success callback //Some markets have switch account function in floating window, the callback means switch succeed.Game client need to wipe the current game role information out.Once return to choosing service interface after switch account successed Please do not call login API again. } public override void onLogoutSuccess (){ //log out success callback // Game client shall wipe current role information,return to login interface,and automatically call login API once. } public override void onPaySuccess (PayResult payResult){ // payment succeed callback //since some markets payment notification is not that accurate, the client notification is just for reference, game client pay the payable goods should according to server notification not client notification. } public override void onPayCancel (PayResult payResult){ // payment cancel callback } public override void onPayFailed (PayResult payResult){ //payment fail callback } public override void onExitSuccess (){ // SDK exit succeed callback // call QuickSDK.getInstance().exitGame()function to exit game, quit course. Please do not use Application.Quit()function ,in order to avoid conflict with market. } }
1.2.2. init (necessarily)
API:void init();
Function: call the init of market SDK
Example:QuickSDK.getInstance().init();
1.2.3. Login (necessarily)
API:void login();
Function: call the login of market SDK
Example:QuickSDK.getInstance().login();
1.2.4. Uploading role information(necessarily)
Note: It is necessary to call upload role information API when creating role, entering game, or updating role.
1.2.4.1. Uploading while creating role
API:void createRole(GameRoleInfo gameRoleInfo);
Function: Uploading role information to market SDK while creating role
Example:
GameRoleInfo gameRoleInfo = new GameRoleInfo(); gameRoleInfo.gameRoleBalance = "0"; gameRoleInfo.gameRoleID = "000001"; gameRoleInfo.gameRoleLevel = "1"; gameRoleInfo.gameRoleName = "real rich"; gameRoleInfo.partyName = "Tong Ji party"; gameRoleInfo.serverID = "1"; gameRoleInfo.serverName = "Mars server"; gameRoleInfo.vipLevel = "1"; gameRoleInfo.roleCreateTime = "roleCreateTime";//UC,dangle.com and 1881 must uploading, the value is 10digit timestamp渠道必传,值为10位数时间戳 gameRoleInfo.gameRoleGender = "male ";//360.com market parameter gameRoleInfo.gameRolePower ="38";//360.com market parameter,set role power level,it must be an integer string gameRoleInfo.partyId ="1100";// 360.com market parameter,set party ID,it must be an integer string gameRoleInfo.professionId = "11";//360.com market parameter,set role profession id,it must be an integer string gameRoleInfo.profession = "Master";//360.com market parameter,set role profession name gameRoleInfo.partyRoleId = "1";//360.com market parameter, set party role id gameRoleInfo.partyRoleName = "Party leader"; //360.com parameter, set role name in party gameRoleInfo.friendlist = "无";//360.com parameter,set friend relationship list, format for reference:http://open.quicksdk.net/help/detail/aid/190 QuickSDK.getInstance ().createRole(gameRoleInfo);//Creating role
1.2.4.2. Uploading while accessing game
API:void enterGame(GameRoleInfo gameRoleInfo);
Function: After login, uploading role information to market SDK while entering game.
Example:QuickSDK.getInstance().enterGame(gameRoleInfo);
1.2.4.3. Uploading when role updating
API:void updateRole(GameRoleInfo gameRoleInfo);
Function: Uploading role information to market SDK while role updating.
Example:QuickSDK.getInstance().updateRole(gameRoleInfo);
GameRoleInfo
string |
type |
instruction |
serverID |
String |
Server ID(value is string) |
serverName |
String |
Server name |
gameRoleName |
String |
Role name |
gameRoleID |
String |
Role ID |
gameRoleBalance |
String |
Role account balance |
vipLevel |
String |
VIP level(value is string) |
gameRoleLevel |
String |
Role level(value is string) |
partyName |
String |
Party/association |
roleCreateTime |
String |
Role create time(10 digits timestamp) |
gameRoleGender |
String |
Role gender(only for 360.com) |
gameRolePower |
String |
Role power(only for 360.com) |
partyId |
String |
Party id(only for 360.com) |
professionId |
String |
Role profession id(only for 360.com) |
profession |
String |
Role profession name(only for 360.com) |
partyRoleId |
String |
Party role id(only for 360.com) |
partyRoleName |
String |
Party role name(only for 360.com) |
friendlist |
String |
Friends list(only for 360.com) |
Access instruction:
1) Uploading role information while creating role, entering game and updating role.
2) All fields in GameRoleInfo can not transfer null, if the game has no field that it will send a default or empty string;
3) More specific instruction of updating role information on 360.com, please refer to:http://open.quicksdk.net/help/detail/aid/190
1.2.5. Fixed payment(necessarily)
API:void pay(OrderInfo orderInfo, GameRoleInfo gameRoleInfo);
Function: call market SDK payment API
Example:
OrderInfo orderInfo = new OrderInfo(); GameRoleInfo gameRoleInfo = new GameRoleInfo(); orderInfo.goodsID = "1"; orderInfo.goodsName = "gouyu"; orderInfo.amount = 1; orderInfo.count = 10; orderInfo.cpOrderID = "cporderidzzw"; orderInfo.extrasParams = "extparma"; orderInfo.price = 0.1f; //(Necessarily for IOS, if only for android there’s no need to transfer) oorderInfo.goodsDesc = "10gouyu"; //(Necessarily for IOS, if it only for android there’s no need to transfer) gameRoleInfo.gameRoleBalance = "0"; gameRoleInfo.gameRoleID = "000001"; gameRoleInfo.gameRoleLevel = "1"; gameRoleInfo.gameRoleName = "Real rich"; gameRoleInfo.partyName = "Tong Ji party"; gameRoleInfo.serverID = "1"; gameRoleInfo.serverName = "Mars server"; gameRoleInfo.vipLevel = "1"; gameRoleInfo.roleCreateTime = "roleCreateTime"; QuickSDK.getInstance ().pay (orderInfo, gameRoleInfo);
OrderInfo
string
type
instruction
goodsID
String
Goods id, to identify the purchased goods
goodsName
String
Goods name
amount
double
Payment amount
count
int
Purchase quantity
cpOrderID
String
Product order(game client order number)
extrasParams
String
Extra parameter
price
float
Unit price (only for ios)
quantifier
String
Quantifier,“yuanbao”means“unit”,“Month card”means“piece”(only for ios)
goodsDesc
String
Goods describe(only for ios)
callbackUrl
String
Payment callback notification address
Access requirement: in order to uniformly show all kinds of market goods name, transfer the order value in following pattern:
Example 1: Example 2:
amount:6.0 amount:10.0
count:60 count:1
goodsName: yuanbao goodsName: month card
goodsName: transfer goods name in “yuanbao”,”diamond”, ”month card” pattern without quantity.
1.2.6. log out account (necessarily)
API:void logout();
Function: call market SDK log out
Example :QuickSDK.getInstance().logout();
1.2.7 Exit(necessarily)
API:void exit();
Function: Exiting game. To confirm whether the market there is exit Dialog by checking isChannelHasExitDialog, if there is exit dialog, call QuickSDK exit API; If there’s no exit dialog ,call game client exit dialog, click “Sure” button,then call QuickSDK exit API.
Example:
if(QuickSDK.getInstance().isChannelHasExitDialog ()){ QuickSDK.getInstance().exit(); } else { //mExitDialogCanvas.SetActive(true); // call game client exit dialog ,click “sure”button,then call QuickSDK.getInstance().exit(); }
1.3.1. Obtain market type
API:int channelType();
Function: Obtain market serial number, distinguish market by it.
1.3.2. Obtain user ID
API:string userId();
Funciton:Obtain user ID
1.3.3. Obtain configuration parameter value
API:string getConfigValue (string key);
Function:Obtain game client user-defined parameter, which can configure in QuickSDK background
1.3.4. Support appoint method ?
API:bool isFunctionSupported(FuncType type);
Function:Testing if there is corresponding function
Instruction: There are some functions such as open/close floating toolbar, enter in user center, enter forum in some SDK. If this method support this function , call it. Defination of appoint method refer to FuncType of QuickSDKImp.cs
1.3.5. call appoint method
API:void callFunction (FuncType type);
Callback information interface: void onSuccess(string infos)
Function: There are some functions such as open/close floating toolbar, enter in user center, enter forum in some SDK. This method can call these functions, details refer to FuncType of QuickSDKImp.cs
Description: Infos is the returned json string
Case: Real name authentication (called after successful login)
OnSuccess will return the encapsulated json entity; Uid (representing user id), age (representing age, which defaults to - 1 if the market does not return a real name), realName (whether the market has a real name: true represents a real name, false represents an unreal name; if the market does not return a real name, which defaults to false), resumeGame (whether the game can continue after the market real name authentication fails: true represents yes, false represents no; if the market does not return a real name, it defaults to true), Other (reserved field, if the market does not return a string that defaults to ""); FunctionType (indicates the function to be called. The value 105 of FuncType.QUICK_SDK_FUNC_TYPE_REAL_NAME_REGISTER indicates real name authentication):
public void onSuccess(string infos) { onSucceed(infos); } QuickSDK.getInstance().callFunction(FuncType.QUICK_SDK_FUNC_TYPE_REAL_NAME_REGISTER); For example, the result form of the callback infos of the test market is: {"uid":"1178471402501092","age":20,"realName":true,"resumeGame":true,"other":"","FunctionType":105}
1.3.6 Call QuickSDK Customer Service Plug-in
API: void enterYunKeFuCenter (GameRoleInfo gameRoleInfo);
Function: First, you need to add QuickSDKCustomService plug-in to the channel configuration interface, then the parent package calls this interface, and then you can perform the channel package operation. After that, the interface can be used to lift the customer service normally
1.3.7 Call market SDK sharing function (Android only)
ShareInfo Class Field Description:
string
type
instruction
titlestring
string
Share Title
content
string
Share content
imgPath
string
Local address for sharing pictures
imgUrl
string
Share picture network address
url
string
Share Link
type
string
Sharing type
shareTo
string
Where to share
extenal
string
Additional remarks
API: void callSDKShare (ShareInfo shareInfo);
Function: Transfer the shared objects specified in QuickSDK (the parameters of the objects should be transferred in after negotiation with the channel). After the channel package is printed, the sharing function of the corresponding channel can be suspended;
1.3.8 Adding the Acquire DeviceId Interface
API: getDeviceId()
Function: Get the DeviceId of the device
Open quicksdk. XML, modify quicksdk. The parameters for their game in the XML file(Please double-click directly in Unity to open, to prevent file format changes from reporting product errors)
Open the AndroidManifest.xml file, modify the game name, horizontal and vertical screen settings
Change the ic_ launcher.png image is replaced with the game's own icon image
Copying the led out myGame.jar pakage and AndroidManfest.xml file to Unity project.
Creating APK refer to following method, the creating APK is game orgin package.
Complement.
Export xcode project and open it by unity.
3.1.1. Landscape game
Export u3d setting as followed, u3d setting will control the switch of game.
3.1.2. Portrait game
Choosing portrait in u3d to export xcode
Adding QuickSDKForIOS in project
Including UnityFramework dynamic library Special instructions:
TargetMembership of files such as. a/. framework/. h/. m needs to be associated with UnityFramework;
TargetMembership and other resource files such as. bundle/. cfg/. png need to be associated with Unity iPhone;
TargetMembership of dynamic libraries such as. framework must be associated with UnityFramework and Unity-iPhone at the same time.
At present, the QuickSDK basic library is a static library, and TargetMembership cannot be associated with UnityFramework and Unity-iPhone at the same time
Adding linking parameters of lib, opening project configuration, Finding Linking Other Linker Flags in Linking of project configuration, adding parameter: -ObjC
Build Settings->Search Paths-> wipe ”” out of all paths in Library Search Paths
PROJECT ->Info ->Configurations Only Release and Debug are reserved
The project info.plist file is configured to allow access to the http network
Importing heading file : #import
Adding initialized method call in UnityAppController.mm
Note 1: The initialization interface needs to be called after setting the application window
Note 2: ProductCode and ProductKey should be replaced by the game's own master package parameters!!!
Is to modify the parameters in the configuration file quickChannel.cfg.
Below iOS Unity5. X, if a crash occurs during callback, please send the QuickSDK_ In ios. mm - (void) sendU3dMessage: (NSString *) messageName: (NSDictionary *) dict Modify:
appid:29
Open:
// char *gameObjectNameCStr = (char *)malloc(100);
// strcpy(gameObjectNameCStr, [_gameObjectName UTF8String]);
// char *messageNameCStr = (char *)malloc(100);
// strcpy(messageNameCStr, [messageName UTF8String]);
// char *jsonStringCStr = (char *)malloc(1000);
// strcpy(jsonStringCStr, [jsonString UTF8String]);
// UnitySendMessage(gameObjectNameCStr, messageNameCStr, jsonStringCStr);
Close:
UnitySendMessage([_gameObjectName UTF8String], [messageName UTF8String], [jsonString UTF8String]);
Open:
// char *gameObjectNameCStr = (char *)malloc(100);
// strcpy(gameObjectNameCStr, [_gameObjectName UTF8String]);
// char *messageNameCStr = (char *)malloc(100);
// strcpy(messageNameCStr, [messageName UTF8String]);
// UnitySendMessage(gameObjectNameCStr, messageNameCStr, "");
Close:
UnitySendMessage([_gameObjectName UTF8String], [messageName UTF8String], "");
Call the registered event listener and the initialization method in didFinishLauchingWithOptions, where the productKey and productCode are obtained by the QuickSDK background.
So far, the master package project has been completed. You can compile and run it and use the quick packaging tool to generate other channel packages. For the use of the packaging tool, please refer to the instructions for the packaging tool.
Note: If the packaged channel ipa runs abnormally on the mobile phone, you can use the debugging project generated by the tool to debug. The debugging project name is game project name channel number.xcodeproj, and the path is in the same directory of the game project.
李先生:13880511661
QQ:48157910
赵先生:15390049857
QQ:1077535763
孙女士:13551010407
QQ:1799614139
QQ群:698731538