TwinBalls project is a basic hypercasual game for Unity mobile platform with Huawei Mobile Services Plugin Remote Configuration integration.
Purpose: Catch yellow balls, avoid red balls.
Remote Configuration Features:
You can update your game parameters without sending an application update to AppGallery.
Such as; changing the speed of turning balls, spawn timers for balls, yellow or red ball spawn chances and score value.
These are the default values in the project.
These are the values on my AppGallery Connect.
Android SDK min 21 Net 4.x
This plugin supports:
- Unity version 2019, 2020 - Developed in master Branch
- Unity version 2018 - Developed in 2.0-2018 Branch
Make sure to download the corresponding unity package for the Unity version you are using from the release section
Please check our wiki page
This is an ongoing project, currently WIP. Feel free to contact us if you'd like to collaborate and use Github issues for any problems you might encounter. We'd try to answer in no more than a working day.
- Register your app at Huawei Developer
- Import the Plugin to your Unity project
- Connect your game with the HMS Kit Managers
1.1- Register at Huawei Developer
During this step, you will create an app in AppGallery Connect (AGC) of HUAWEI Developer. When creating the app, you will need to enter the app name, app category, default language, and signing certificate fingerprint. After the app has been created, you will be able to obtain the basic configurations for the app, for example, the app ID and the CPID.
- Sign in to Huawei Developer and click Console.
- Click the HUAWEI AppGallery card and access AppGallery Connect.
- On the AppGallery Connect page, click My apps.
- On the displayed My apps page, click New.
- Enter the App name, select App category (Game), and select Default language as needed.
- Upon successful app creation, the App information page will automatically display. There you can find the App ID and CPID that are assigned by the system to your app.
Set the package name of the created application on the AGC.
- Open the previously created application in AGC application management and select the Develop TAB to pop up an entry to manually enter the package name and select manually enter the package name.
- Fill in the application package name in the input box and click save.
Your package name should end in .huawei in order to release in App Gallery
Create a keystore using Unity or Android Tools. make sure your Unity project uses this keystore under the Build Settings>PlayerSettings>Publishing settings
During this step, you will need to export the SHA-256 fingerprint by using keytool provided by the JDK and signature file.
-
Open the command window or terminal and access the bin directory where the JDK is installed.
-
Run the keytool command in the bin directory to view the signature file and run the command.
keytool -list -v -keystore D:\Android\WorkSpcae\HmsDemo\app\HmsDemo.jks
-
Enter the password of the signature file keystore in the information area. The password is the password used to generate the signature file.
-
Obtain the SHA-256 fingerprint from the result. Save for next step.
During this step, you will configure the generated SHA-256 fingerprint in AppGallery Connect.
- In AppGallery Connect, click the app that you have created and go to Develop> Overview
- Go to the App information section and enter the SHA-256 fingerprint that you generated earlier.
- Click √ to save the fingerprint.
To import the plugin:
- Download the .unitypackage
- Open your game in Unity
- Choose Assets> Import Package> Custom
- In the file explorer select the downloaded HMS Unity plugin. The Import Unity Package dialog box will appear, with all the items in the package pre-checked, ready to install.
- Select Import and Unity will deploy the Unity plugin into your Assets Folder
In order for the plugin to work, some kits are in need of agconnect-json file. Please download your latest config file from AGC and import into Assets/StreamingAssets folder.
In order for the plugin to work, you need to select the needed kits Huawei > Kit Settings.
In this Remote Configuration reference game , I selected the Remote Config.
Remote Config is dependent on Analytics Kit. But don't worry, plugin will automatically select it for you. It will automaticaly create the GameObject for you and it has DontDestroyOnLoad implemented so you don't need to worry about reference being lost.
Now you need your game to call the Remote Config Manager from your game. See below for further instructions.
There is a custom editor in Huawei > Kit Settings > Ads tab.
You can add and use default values if user does not have an active internet connection to get parameters from AppGallery. Insert your key name and value to create these default values.
If you check "Apply Default Values" checkbox, it will automatically apply these values. If you want to turn on developer mode, simply checking the "Developer Mode" checkbox will enable that for you.
Then you can call certain functions such as
HMSRemoteConfigManager.Instance.GetValueAsFloat(floatKey);
HMSRemoteConfigManager.Instance.GetValueAsDouble(doubleKey);
HMSRemoteConfigManager.Instance.GetMergedAll(); // Returns all values obtained after the combination of the default values and values in Remote Configuration.
HMSRemoteConfigManager.Instance.Fetch(); // Fetches latest parameter values from Remote Configuration at a customized interval. If the method is called within an interval, cached data is returned.
This reference game project's GameManager script can be observed as an example for remote configuration integration.
1.If you received package name error , please check your package name on File->Build Settings -> Player Settings -> Other Settings -> Identification
2.If you received min sdk error ,
please set your API level as implied in the Requirements section