In the constructor of the MgAndroidSdkProcessorScript.cs script, InitBegin() is called to initialize the mgsdk and turn on the mask。 The onInitSdkResult method is called when the initialization result is returned
void InitBegin() { MgSdkConfig config = new MgSdkConfig(); //Configure the corresponding properties here config.AppKey = "0B51BDA9F7";//Required, apply identity config.CallbackId = "";//Optional, payment callback ID string s = config.toJson(); mgSdkProcessor.initSDK(config);//Perform mgsdk initialization } void onInitSdkResult (String message) { //messageIs separated by commas”success,xxx,yyy,zzz” string param = "";//Additional parameters string result = parseMessage(message, out param); //Parsing Android messages if (result == "success")//Success returned, otherwise failure { isInit = true; showLogin();//Login window can be displayed here } else { Debug.LogError("Failed to initialize mgsdk:" + param); } }
You can call showLogin () to display the landing window in the initialization successfully callback onInitSdkResult.。 After successful login, the onLoginSuccess method will be called
void onLoginSuccess(String message) { //Close the mask after landing successfully. Users can play UIEventMaskEnd(); }
Where payment is needed, call Payment and pass in the parameter MgAndroidSdkProcessorScript.Instance.Payment(“Commodity key, Mg generated in the background "," user-defined data, can be order number”).
void onPaymentResult(String message) { string param = "";//Additional parameters string result = parseMessage(message, out param); //Parsing Android messages if (result == "success")//Successful returnsuccess,Parsing Android messages Debug.LogError("Successful payment:" + param); } else { Debug.LogError("Failure to pay:" + param); } UIEventMaskEnd(); //Close the mask after payment failure. Users can play }