Give players a reason to return each day
Let players claim a reward on each day they log in, plus an extra reward for completing three adventures. Continue with the tutorial project and account you have been using.
1. Configure login rewards
Give 10 coins on day 1, 20 on day 2, and 30 on day 3. The day changes at midnight Japan Standard Time (JST, UTC+9). If a player skips a day, they resume from their next unclaimed reward.
Add Login Rewards and Missions from Add features.
Open Tables → Login Rewards → LoginRewardCollection and create the following row.
| Field | Value |
|---|---|
| ID | daily |
| Progression mode (mode) | streaming |
| Daily reset hour (resetHour) | 15 (15:00 UTC = midnight JST) |
| Repeat (repeat) | disabled |
| Missed reward relief (missedReceiveRelief) | disabled |
In LoginReward, add day1, day2, and day3, and set the bonus group to daily for all three.
For each row, open Acquire actions → Add item → Not set. Select DepositByUserId (money2) as the action and None as the target resource.
| Field | Value |
|---|---|
| namespaceName | Currency |
| userId | #{userId} |
| slot | 0 |
Add one entry to depositTransactions. Set price to 0 and currency to No value. Set count to 10 for day1, 20 for day2, and 30 for day3.
Download the login rewards and missions template.
- In the management console’s Tokyo region, open Deploy → Stack list → Create stack.
- Name the stack
adventure-daily, select the downloaded JSON file under Template data, and create it. - Once the status is Create complete, you can use
adventure-login-rewardandadventure-mission.
The login reward settings are under LoginRewardMaster → Properties → Settings → bonusModels.
| Field | Value |
|---|---|
| name | daily |
| mode | streaming |
| resetHour | 15 |
| repeat | disabled |
| missedReceiveRelief | disabled |
| rewards | Three deposits: 10, 20, and 30 coins, in that order |
This stack adds only login reward and mission settings. Adventures, coins, and stamina continue to use the existing adventure-game stack.
2. Create a mission to complete three adventures
Create a mission counter that increases by one whenever an adventure is completed. Once it reaches three, let the player claim 30 coins with a button.
Open Tables → Missions → MissionSetting and click Add row. Set the reset hour to 15, weekly reset day to sunday, and monthly reset day to 1.
Next, add rows to these three tables.
| Table | ID | Settings |
|---|---|---|
| Mission counter (MissionCounter) | clear | Enter only the ID |
| Mission group (MissionCollection) | adventure | Reset type notReset; leave the schedule empty |
| Mission (Mission) | clear3 | Mission group adventure, progress counter clear, target 3 |
Add DepositByUserId (money2) to Completion rewards for clear3. Use the same settings as the login rewards: namespaceName = Currency, userId = #{userId}, slot = 0, and one depositTransactions entry with price = 0, no currency value, and count = 30.
Open Tables → Quests → Quest. Add the following action to Completion rewards for both forest and cave. Keep the existing coin deposit actions.
| Field | Value |
|---|---|
| Action | IncreaseCounterByUserId (mission) |
| Target resource | None |
| namespaceName | Mission |
| userId | #{userId} |
| counterName | clear |
| value | 1 |
Save and deploy from Publish → Calculate server differences, then run Update the Unity project.
The adventure-daily stack you created already contains this mission.
| Setting | Value |
|---|---|
| Group | adventure, no reset |
| Counter | clear, cumulative total |
| Mission | clear3, target 3 |
| Reward | 30 coins in slot 0 of adventure-coin |
Open the template you used for adventure-game. In contents → completeAcquireActions for both forest and cave, add the following entry at the same level as the existing deposit action.
- action: Gs2Mission:IncreaseCounterByUserId
request: |-
{"namespaceName":"adventure-mission","userId":"#{userId}","counterName":"clear","value":1}Open Deploy → adventure-game → Update stack, select the edited file under Template data, and update the stack. Wait for Update complete. Quest completion now deposits coins and increases the counter.
3. Add reward buttons in Unity
Add login reward and mission reward buttons to the adventure screen. Continue using OnGUI() to display them.
Add the handlers
Stop Play Mode in Unity and add the following components to Gs2 in the Hierarchy.
- Login Reward Collection Handler
- Mission Handler
- Mission Counter Handler
Add reward buttons to the adventure screen
- Download this chapter’s AdventureStudioView.cs and replace
Assets/AdventureStudioView.cs. - In Adventure Studio View on
Gs2, assign the handlers you just added to Login Reward, Mission, and Counter. Set Mission Group toadventureand Mission Name toclear3. - Enter Play Mode and log in. Reward buttons and progress appear below the stamina shop.
The existing OnGUI() calls the new DrawDailyRewards() method. Button actions follow the same pattern as starting and completing adventures.
if (GUILayout.Button("Claim today's login reward"))
Run(() => loginReward.Binder.Receive());
if (GUILayout.Button("Claim 30-coin mission reward"))
Run(() => mission.Binder.Receive());The downloadable code disables actions while loading or processing, and enables the mission reward button once the mission is complete.
The Binder waits for the transaction to finish internally, so the view does not need to call WaitAsync(). Read the Handler’s Model when rendering. Changes from claiming rewards and completing adventures are reflected in the Handler too.
Enter Play Mode, log in, and click Claim today’s login reward. Day 1 becomes “Claimed” and the adventure screen shows 10 more coins. Clicking again on the same day does not add more coins.
Next, complete Forest exploration three times. After deployment, the new counter action can take up to five minutes to take effect. If the count does not increase, wait a little, then start and complete another forest quest. Once the total reaches 3, Claim 30-coin mission reward becomes available. Claim it to mark the mission “Claimed” and receive 30 coins in addition to the normal adventure rewards.
Stop Play Mode and create an empty GameObject named Extensions. Place AdventureDaily.cs in Assets/AdventureExtensions, then add Adventure Daily to Extensions. Assign the scene’s AdventureLogin to Login, set Mission Group to adventure, and Mission Name to clear3.
In the sample, Client returns the GS2 client and Session returns the signed-in player’s session. Both come from AdventureLogin.
Reward buttons call through RunWrite(). It assigns a key to each request and passes it as requestId to ReceiveLogin() or ReceiveMission(). After a connection error, Retry the same operation sends the same request. As in chapter 8, keep Play Mode running and retry as soon as the connection is restored.
This sample uses OnGUI() to draw reward buttons and progress to the right of the adventure screen. Widen the Game view so both panels are visible, enter Play Mode, and log in. Click Claim today’s login reward. Day 1 becomes “Claimed” and the coin balance on the left increases by 10. Clicking again does not grant the same day’s reward twice.
Claim status and mission progress are subscribed to with SubscribeWithInitialCallAsync(). Change notifications update the display when an adventure is completed or a reward is claimed.
On subsequent days, players can claim day 2 and then day 3. The following API claims the reward.
private async UniTask ReceiveLogin(string requestId)
{
var transaction = await Client.LoginReward.Namespace(LoginNamespace).Me(Session).Bonus()
.ReceiveAsync("daily", speculativeExecute: false, duplicationAvoider: requestId);
if (transaction != null) await transaction.WaitAsync(all: true);
}Next, complete Forest exploration three times using the left panel. After deployment, the new counter action can take up to five minutes to take effect. If the count does not increase, wait a little, then start and complete another forest quest. When the total on the right reaches 3, click Claim 30-coin mission reward. The status becomes “Claimed” and the coin balance on the left increases by 30, in addition to the usual adventure rewards.
private async UniTask ReceiveMission(string mission, string requestId)
{
var transaction = await Client.Mission.Namespace(MissionNamespace).Me(Session).Complete(missionGroup)
.ReceiveRewardsAsync(mission, speculativeExecute: false, duplicationAvoider: requestId);
if (transaction != null) await transaction.WaitAsync(all: true);
}4. Add a Monday-only mission
Add a mission that grants 30 coins for completing one adventure on Monday. Once completed on Monday, its reward can also be claimed from Tuesday through Sunday. Completion and claim status reset at midnight on the next Monday, allowing another attempt. All days and times in this example use JST (UTC+9).
Keep clear3, and add monday_clear to a new weekly group named weekly.
Create a Monday schedule
Under Tables → Scheduling → Schedule, add the following row. For the start and end dates, open each cell, switch to Local (UTC+9), and select the date and time.
| Field | Value |
|---|---|
| ID | monday |
| Schedule type | absolute |
| Start | 2020-01-01 00:00 (JST) |
| End | 2099-01-01 00:00 (JST) |
| Repeat type | weekly |
| Start day | sunday |
| Start hour | 15 |
| End day | monday |
| End hour | 15 |
The start and end dates define the overall period during which this weekly event runs. The repeat settings make it active only on Mondays within that period. The weekday and hour fields use UTC, so midnight Monday through midnight Tuesday in JST is sunday 15 through monday 15.
Create the weekly mission
The reset occurs at midnight Monday JST (sunday and 15 in the mission settings).
- Add
weeklyto MissionCollection. Set the reset type toweeklyand schedule tomonday. - Add
monday_clearto Mission. Set the group toweekly, counter toclear, and target to1. The completion reward is 30 coins, as forclear3. - Save and deploy from Publish → Calculate server differences, then run Update the Unity project.
- Stop Play Mode. In Adventure Studio View on
Gs2, change Mission Group toweeklyand Mission Name tomonday_clear.
- Download the Monday-only mission template.
- Open Deploy → adventure-daily → Update stack, select the file under Template data, and update. Wait for Update complete.
- Stop Play Mode. In Adventure Daily, change Mission Group to
weeklyand Mission Name tomonday_clear.
The template includes the login rewards, the original clear3, and these additional settings. You do not need to change any dates.
| Setting | Details |
|---|---|
Schedule monday | Active every Monday from midnight until midnight Tuesday (JST) |
Group weekly | Resets completion and claim status every Monday at midnight (JST) |
Mission monday_clear | Counter clear, target 1, reward 30 coins |
The schedule’s repeat settings are shown below. GS2 uses UTC for weekdays and hours, so midnight Monday through midnight Tuesday JST is specified as Sunday 15:00 through Monday 15:00.
"repeatSetting": {
"repeatType": "weekly",
"beginDayOfWeek": "sunday",
"beginHour": 15,
"endDayOfWeek": "monday",
"endHour": 15
}The mission’s challengePeriodEventId references this schedule. The group reset settings are resetType = weekly, resetDayOfWeek = sunday, and resetHour = 15.
The new mission settings can take up to five minutes to take effect after deployment. Wait five minutes, enter Play Mode, log in, and complete Forest exploration once. On Monday, the screen says “You can claim the 30-coin mission reward.” From Tuesday through Sunday, that completion does not fulfill the mission.
The counter uses the existing cumulative total. Mission completion is evaluated when an adventure increases the counter, so even if the total is already at least one, you must complete another adventure on Monday.
| When | Mission behavior |
|---|---|
| Complete an adventure on Monday | Completes the mission; 30 coins can be claimed |
| Tuesday through Sunday | Cannot newly complete the mission; a reward earned on Monday can still be claimed |
| Midnight on the next Monday | Completion and claim status reset; unclaimed rewards from the previous week do not carry over |