|
| 1 | +<p align="left"> |
| 2 | + <a> |
| 3 | + <img alt="Made With Unity" src="https://img.shields.io/badge/made%20with-Unity-57b9d3.svg?logo=Unity"> |
| 4 | + </a> |
| 5 | + <a> |
| 6 | + <img alt="License" src="https://img.shields.io/github/license/wolf-package/remote-config-manager-unity?logo=github"> |
| 7 | + </a> |
| 8 | + <a> |
| 9 | + <img alt="Last Commit" src="https://img.shields.io/github/last-commit/wolf-package/remote-config-manager-unity?logo=Mapbox&color=orange"> |
| 10 | + </a> |
| 11 | + <a> |
| 12 | + <img alt="Repo Size" src="https://img.shields.io/github/repo-size/wolf-package/remote-config-manager-unity?logo=VirtualBox"> |
| 13 | + </a> |
| 14 | + <a> |
| 15 | + <img alt="Last Release" src="https://img.shields.io/github/v/release/wolf-package/remote-config-manager-unity?include_prereleases&logo=Dropbox&color=yellow"> |
| 16 | + </a> |
| 17 | +</p> |
| 18 | + |
| 19 | +## What |
| 20 | +- Tool support use firebase remote config for game unity |
1 | 21 | ## How To Install
|
2 | 22 |
|
3 | 23 | ### Add the line below to `Packages/manifest.json`
|
4 | 24 |
|
5 |
| -for version `x.x.x` |
| 25 | +for version `1.0.0` |
| 26 | +```csharp |
| 27 | +"com.wolf-package.remote-config":"https://github.com/wolf-package/remote-config-manager-unity.git#1.0.0", |
| 28 | +``` |
| 29 | +dependency `extensions-unity-1.0.1` |
| 30 | +```csharp |
| 31 | +"com.wolf-package.extensions":"https://github.com/wolf-package/extensions-unity.git#1.0.1", |
| 32 | +``` |
| 33 | +If you use [game-data-unity](https://github.com/wolf-package/game-data-unity), add the library below and define symbol `VIRTUESKY_DATA` |
| 34 | +```csharp |
| 35 | +"com.wolf-package.game-data":"https://github.com/wolf-package/game-data-unity.git#1.0.0", |
| 36 | +``` |
| 37 | + |
| 38 | +## Use |
| 39 | + |
| 40 | +- Add `Define symbol` to use remote config (`VIRTUESKY_FIREBASE`, `VIRTUESKY_FIREBASE_REMOTECONFIG`) |
| 41 | + |
| 42 | +- Attach `FirebaseRemoteConfigManager` to scene (don't destroy). Please add a `Remote Config Data` to the list, then enter the key, select the corresponding data type (int, bool, string), enter the default value. Finally, click `Generate Remote Data` when you have finished setup. |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +- After clicking `Generate Remote Data`, the `RemoteData.cs` script will be automatically generated and formatted as below. |
| 47 | + |
6 | 48 | ```csharp
|
7 |
| -"com.virtuesky._package_name_":"https://github.com/VirtueSky/_package_name_.git#x.x.x", |
| 49 | + |
| 50 | +namespace VirtueSky.RemoteConfigs |
| 51 | +{ |
| 52 | + public struct RemoteData |
| 53 | + { |
| 54 | + public const string KEY_RMC_LEVEL_TURN_ON_INTER_ADS = "RMC_LEVEL_TURN_ON_INTER_ADS"; |
| 55 | + public const int DEFAULT_RMC_LEVEL_TURN_ON_INTER_ADS = 5; |
| 56 | + public static int RMC_LEVEL_TURN_ON_INTER_ADS => VirtueSky.DataStorage.GameData.Get(KEY_RMC_LEVEL_TURN_ON_INTER_ADS, DEFAULT_RMC_LEVEL_TURN_ON_INTER_ADS); |
| 57 | + public const string KEY_RMC_INTER_CAPPING_LEVEL = "RMC_INTER_CAPPING_LEVEL"; |
| 58 | + public const int DEFAULT_RMC_INTER_CAPPING_LEVEL = 2; |
| 59 | + public static int RMC_INTER_CAPPING_LEVEL => VirtueSky.DataStorage.GameData.Get(KEY_RMC_INTER_CAPPING_LEVEL, DEFAULT_RMC_INTER_CAPPING_LEVEL); |
| 60 | + public const string KEY_RMC_INTER_CAPPING_TIME = "RMC_INTER_CAPPING_TIME"; |
| 61 | + public const int DEFAULT_RMC_INTER_CAPPING_TIME = 8; |
| 62 | + public static int RMC_INTER_CAPPING_TIME => VirtueSky.DataStorage.GameData.Get(KEY_RMC_INTER_CAPPING_TIME, DEFAULT_RMC_INTER_CAPPING_TIME); |
| 63 | + public const string KEY_RMC_ON_OFF_INTER = "RMC_ON_OFF_INTER"; |
| 64 | + public const bool DEFAULT_RMC_ON_OFF_INTER = true; |
| 65 | + public static bool RMC_ON_OFF_INTER => VirtueSky.DataStorage.GameData.Get(KEY_RMC_ON_OFF_INTER, DEFAULT_RMC_ON_OFF_INTER); |
| 66 | + public const string KEY_RMC_ON_OFF_BANNER = "RMC_ON_OFF_BANNER"; |
| 67 | + public const bool DEFAULT_RMC_ON_OFF_BANNER = true; |
| 68 | + public static bool RMC_ON_OFF_BANNER => VirtueSky.DataStorage.GameData.Get(KEY_RMC_ON_OFF_BANNER, DEFAULT_RMC_ON_OFF_BANNER); |
| 69 | + public const string KEY_RMC_LEVEL_SHOW_RATE_AND_REVIEW = "RMC_LEVEL_SHOW_RATE_AND_REVIEW"; |
| 70 | + public const int DEFAULT_RMC_LEVEL_SHOW_RATE_AND_REVIEW = 3; |
| 71 | + public static int RMC_LEVEL_SHOW_RATE_AND_REVIEW => VirtueSky.DataStorage.GameData.Get(KEY_RMC_LEVEL_SHOW_RATE_AND_REVIEW, DEFAULT_RMC_LEVEL_SHOW_RATE_AND_REVIEW); |
| 72 | + public const string KEY_RMC_ON_OFF_RATE_AND_REVIEW = "RMC_ON_OFF_RATE_AND_REVIEW"; |
| 73 | + public const bool DEFAULT_RMC_ON_OFF_RATE_AND_REVIEW = true; |
| 74 | + public static bool RMC_ON_OFF_RATE_AND_REVIEW => VirtueSky.DataStorage.GameData.Get(KEY_RMC_ON_OFF_RATE_AND_REVIEW, DEFAULT_RMC_ON_OFF_RATE_AND_REVIEW); |
| 75 | + public const string KEY_RMC_VERSION_UPDATE = "RMC_VERSION_UPDATE"; |
| 76 | + public const string DEFAULT_RMC_VERSION_UPDATE = "1.0"; |
| 77 | + public static string RMC_VERSION_UPDATE => VirtueSky.DataStorage.GameData.Get(KEY_RMC_VERSION_UPDATE, DEFAULT_RMC_VERSION_UPDATE); |
| 78 | + public const string KEY_RMC_CONTENT_UPDATE = "RMC_CONTENT_UPDATE"; |
| 79 | + public const string DEFAULT_RMC_CONTENT_UPDATE = "Update Content"; |
| 80 | + public static string RMC_CONTENT_UPDATE => VirtueSky.DataStorage.GameData.Get(KEY_RMC_CONTENT_UPDATE, DEFAULT_RMC_CONTENT_UPDATE); |
| 81 | + } |
| 82 | +} |
| 83 | + |
8 | 84 | ```
|
| 85 | + |
| 86 | +- Handle |
| 87 | + |
| 88 | +From the `RemoteData` script, you can retrieve `key data`, `default values`, and `data` fetched from firebase remote configuration. |
| 89 | + |
| 90 | +Example |
| 91 | + |
| 92 | +```csharp |
| 93 | + |
| 94 | + void HandleBannerAds() |
| 95 | + { |
| 96 | + if (RemoteData.RMC_ON_OFF_BANNER) |
| 97 | + { |
| 98 | + // show banner ads |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | +``` |
0 commit comments