This is an implementation of a progress bar for watching rewarded videos.
The player receives a sequence of rewards. To claim the most valuable reward at the end, all previous videos must be watched in order.
The system is already used in the game Eco City.
Store link: Google Play
The system generates a set of rewards for the progress bar, displays them as buttons, manages their states (available, claimed, locked), and handles ad playback through the IAdsService abstraction.
After a successful ad view, the reward is granted and a collection animation is played.
When all rewards in the set are obtained, a cooldown period begins before the next set becomes available.
- Progressive reward system where the final slot is unique and becomes available only after watching all previous videos
- Reward generation based on rarity and weighted values (
spawnWeight) - Simple integration with any SDK via the
IAdsServiceinterface and theAdsEventsevent hub - Mock mode for local testing without a real Ads SDK
- Inspector configuration for timers and cooldown durations
- Progress bar state persistence in
ProgressBarSaveData
| Script | Description |
|---|---|
RewardPoolManager (ScriptableObject) |
Generates the GeneratedReward array |
| ProgressBarController | Manages UI logic, timers, and button animations |
| RewardButton | Component for each progress bar cell, includes collection animation |
| RewardGrantManager | Converts GeneratedReward into real in-game actions via ExternalHooks |
| AdManager | High-level ad controller that uses IAdsService and AdsEvents |
| MockAdsService | Convenient for local functionality testing |
- Copy the script folder into your Unity project.
- Create a
RewardPoolManagerasset through Create → Asset and fill in theallRewardsandallCurrencieslists. - Prepare a UI prefab with buttons. Attach a
RewardButtoncomponent to each one, set theflyEndpoint, and assign the required image references. - Place a
ProgressBarControllerin the scene and link:rewardButtonsnodeImageschainImagesendpointrewardsWindowandcooldownWindow
- Add
AdManagerandAdsEventsto the scene. By default, the editor connectsMockAdsService, allowing testing without an SDK. - Open the DemoScene and press Play to check the behavior.
- Implement the
IAdsServiceadapter for your SDK. - Add the define symbol
USE_ADMOBorUSE_YANDEXin your build settings so thatAdManagerautomatically selects the appropriate implementation. - The adapter should call:
AdsEvents.Instance.InvokeAdLoadedInvokeRewardedInvokeAdDismissedInvokeAdFailedToLoad
according to the ad lifecycle.
- The example includes a class
ExternalHookswith actions:OnOpenResourceRewardOnAddCoinsOnAddCrystalsOnStartPlacingBuildingOnShowMessage
- Connect these hooks to your UI and economy managers for smooth integration with your project.
- For local testing, use
MockAdsService. It instantly marks ads as ready and simulates a successful view. - Check the following scenarios:
- Open the progress bar when a reward set is available
- Click an available button, watch the ad, and receive a reward
- Try clicking a locked button to ensure it does not start ad playback
- Collect all rewards and verify that the cooldown starts and the window switches
ProgressBarControllerprovides methodsGetSaveDataandLoadFromSaveDatato store thecollectedarray and generated rewards.GeneratedRewardis serialized through the compact structureGeneratedRewardSerializableusing identifiers.
- Adjust rarity weights and
spawnWeightinRewardDatato control probability. - Tune
rewardDisplayDurationSecondsandnextProgressBarCooldownSecondsto configure activity and cooldown cycles. - Button animations are implemented using DOTween Sequences. Replace them with Animator or another plugin if needed.
If you need build instructions or a short demo scene, let me know and I will prepare text for the README or inspector examples.