05/15/2024 15:19:45

Unity Access Guide

I. Import Plugins

II. Environment Configuration

Follow the GCloudSDK documentation guidelines to import the SDK into the project.

2.1 Environment Configuration

For details, please refer to Configure Environment documentation.

III. Access functions

3.1 Register MSDK initialization callback (PIX version must handle this)

1) Function description

Receive the callback after MSDK initialization is completed. The game needs to register a callback function for processing. The game needs to wait for the callback to complete before it can start invoking the functional interfaces of other MSDK modules.

2) Interface declaration

C#
/// <summary>
//  MSDK initialization callback
/// <summary>
public static event OnMSDKRetEventHandler<MSDKBaseRet> InitRetEvent;

3) Demo code

C#
MSDK.InitRetEvent += OnInitRetEvent;

private void OnInitRetEvent(MSDKBaseRet baseRet)
{
	Debug.Log ("OnInitRetEvent in MSDK");

	if (baseRet.retCode == MSDKError.SUCCESS) {
		Debug.Log ("MSDK is initialized successfully. ");
		//MSDK interfaces can be invoked at this time
	} else {
		Debug.Log ("Failed to initialize MSDK.");
	}
}

3.2 Initialize MSDK

It is needed to execute the MSDK.Init method at the beginning of the game to initialize the MSDK module.

C#
MSDK.isDebug = true; // The Unity layer sets MSDK to the Debug mode, so that it can print more levels of logs (if it sets "MSDK.isDebug"     to false, it can only print the error level of logs); native logs are configured through MSDKConfig.ini. For details, please refer to "2. Configuration environment"
MSDK.Init ();

3.23 MSDK Function Module

Call of the MSDK function module. Please refer to the call method in the Function Module documentation.

IV.Packaging

(1) Android's Environment Configuration

  • It is recommended to use the Gradle packaging scheme. For specific schemes, you can consult related GCloud colleagues.
  • If you use the ADT packaging mode, when you encounter the problem that the number of methods exceeds the limit, you need to use Android MultiDex scheme. For details, please consult related GCloud colleagues.

(2) iOS's Environment Configuration

  • iOS uses XUPorter for packaging. It is needed to pay attention to MSDK-related configurations.
  • For details, please consult related GCloud colleagues.



Copyright © 2024 MSDK.
All rights reserved.

results matching ""

    No results matching ""