Ads

개요

This demo banks one point each time an ad view completes and spends one point when a reward is claimed. The showroom runs as a WebGL page in the browser, where the mobile-only ad SDKs (Unity Ads, LevelPlay, AdMob) cannot run, so no real advertisement plays. Instead a panel stands in for the ad placement, and everything after the title decides “the view finished”, which is GS2’s part, runs for real.

체험 방법

  1. Balance under Ad view point shows the banked points, e.g. 0 view(s) banked.
  2. Press Ad break; an Advertisement panel opens and explains why no ad plays. Wait for the You can continue in 5s. countdown to finish.
  3. Press I finished watching; the page tells GS2 the view completed and asks for the point, and Balance goes up by 1. Pressing Close instead grants nothing.
  4. Press Spend; one point is consumed and Balance goes down by 1.

In a shipped title, the point is granted from the ad network’s completion callback where I finished watching sits here. Deciding that a view really happened is the title’s job.

사용하는 GS2 서비스

  • GS2-AdReward: A GS2-AdReward namespace holds each player’s view points. Points are granted with Gs2AdReward:AcquirePointByUserId and consumed with Gs2AdReward:ConsumePointByUserId; granting does not verify the view itself.
  • GS2-Exchange: Two GS2-Exchange rates define the transactions that grant one point (I finished watching) and consume one point (Spend), and run them server-side automatically.

GS2 Studio에서 사용하기

GS2 Studio의 Simple 모드에서 Add features 를 열고 Ads 의 Add 를 누르면 이 기능을 자신의 프로젝트에 가져올 수 있습니다. 패키지를 직접 지정하려면 Add from GitHub 를 선택하고 아래 패키지를 입력합니다.

https://github.com/gs2io/gs2-studio-package/tree/main/foundation-economy-ad/packages/foundation-economy-ad
  • Owner: gs2io
  • Repository: gs2-studio-package
  • Subdirectory: foundation-economy-ad/packages/foundation-economy-ad

소스 코드