Integrating Game Services in Unity Game Development

In this article, we will learn to integrate HMS Game Services in Unity Game Development. Huawei Game Services provides various services.

Shiddalingeshwar M S
4 min readJan 6, 2021

Introduction

In this article, we will learn to integrate HMS Game Services in Unity Game Development. Huawei Game Services provides various services. Services covered, as follows.

1. Game Service Login

2. Achievements

3. Leader Board Data

4. Current Player Info & Extra Info

5. Game Event begin & end

Requirements:

1. Unity 3D IDE

2. Visual Studio Code

3. HMS Device

4. Huawei Developer ID

Steps to integrate:

  1. Create a 2D/3D Project in unity.

2. Add and import HMS AGC Services to Unity project from

below link.

3. Once import is successful, verify import in directory.

Choose Assets > HuaweiHms path, as follows.

4. Navigate to AGC console and Create a New Project. Also download agconnect-services.json and copy to

Assets > Plugins > Android.

5. Add configurations to project as follows.

Choose File > Build Settings

Choose File > Build Settings > Project Settings > Player.

6. Add SHA-256 fingerprint to AGC.

Open Command prompt terminal execute the command below.

keytool -list -v -keystore D:\unity\games\new3dgame\user.keystore

7. Add plugin and dependencies in LaucherTemplate

apply plugin: ‘com.huawei.agconnect’

implementation ‘com.huawei.agconnect:agconnect-core:1.4.1.300’

implementation ‘com.huawei.hms:base:5.0.0.301’

implementation ‘com.huawei.hms:hwid:5.0.3.301’

implementation ‘com.huawei.hms:game:5.0.1.302’

8. Add the following dependencies in MainTemplate.

implementation ‘com.huawei.agconnect:agconnect-core:1.4.1.300’

implementation ‘com.huawei.hms:base:5.0.0.301’

implementation ‘com.huawei.hms:hwid:5.0.3.301’

implementation ‘com.huawei.hms:game:5.0.1.302’

9. Add dependencies in build script repositories and all project repositories and class path in BaseProjectTemplate.

maven { url ‘https://developer.huawei.com/repo/' }

classpath ‘com.huawei.agconnect:agcp:1.2.1.301’

10. Add Achievement details in AGC > My apps

11. Add LeaderBoard details.

12. Add Events list.

13. Create Empty Game object rename to GameManager, UI canvas texts & buttons as shown below.

Add onclick events to respective function in the GameManager.cs.

14. To build apk and run in device File > Build Settings > Build

for apk or Build And Run for run on connected device.

15. Result

Tricks and Tips

· Add agconnect-services.json file in without fail.

· Add SHA-256 fingerprint without fail.

· Add Achievements and LeaderBoard details before run.

Conclusion

In this article, we have learnt integration of HMS GameService Kit In Unity based game.

Error code while fetching Player extra information and Event begin & end.

7006: The account has not been registered in the Chinese mainland. In this case, perform bypass and no further action is required.

Thanks for reading please do like and comment your queries/suggestions.

References

Hms game services

--

--

No responses yet