Created
November 27, 2017 08:41
-
-
Save mukae-ss/9131fa350e09db77dbab247500c94750 to your computer and use it in GitHub Desktop.
アドジェネ動画リワードUnityPluginの国別判定
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.UI; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Runtime.InteropServices; | |
public class SDKTest : MonoBehaviour { | |
public enum InitializeState { | |
AUTO = 0, | |
WEIGHT, | |
ALL, | |
WIFIONLY | |
}; | |
private string placementID; | |
// Use this for initialization | |
void Start() { | |
// Something to do | |
// Test mode & Debug mode | |
VAMPUnitySDK.setTestMode(false); | |
VAMPUnitySDK.setDebugMode(false); | |
VAMPUnitySDK.getCountryCode(gameObject); | |
} | |
// getCountryCodeメソッドの取得結果が通知されます | |
void VAMPCountryCode(string code) { | |
Debug.Log("Country=" + code); | |
#if UNITY_IOS | |
if (code == "JP") // 日本 | |
{ | |
this.placementID = "<広告枠ID>"; | |
} | |
else if (code == "EN") // 英語圏 | |
{ | |
this.placementID = "<広告枠ID>"; | |
} | |
else if (code == "KR") // 韓国 | |
{ | |
this.placementID = "<広告枠ID>"; | |
} | |
else if (code == "TW") // 台湾 | |
{ | |
this.placementID = "<広告枠ID>"; | |
} | |
else // その他地域 | |
{ | |
this.placementID = "<広告枠ID>"; | |
} | |
#elif UNITY_ANDROID | |
if (code == "JP") // 日本 | |
{ | |
this.placementID = "<広告枠ID>"; | |
} | |
else if (code == "EN") // 英語圏 | |
{ | |
this.placementID = "<広告枠ID>"; | |
} | |
else if (code == "KR") // 韓国 | |
{ | |
this.placementID = "<広告枠ID>"; | |
} | |
else if (code == "TW") // 台湾 | |
{ | |
this.placementID = "<広告枠ID>"; | |
} | |
else // その他地域 | |
{ | |
this.placementID = "<広告枠ID>"; | |
} | |
#endif | |
// 各アドネットワークSDKの初期化 | |
VAMPUnitySDK.initializeAdnwSDK(this.placementID, InitializeState.WIFIONLY.ToString(), 5); | |
// 国コードで判別したplacementIDをセットしVAMP SDKを初期化 | |
VAMPUnitySDK.initVAMP(gameObject, this.placementID); | |
} | |
// Update is called once per frame | |
void Update() { | |
// Something to do | |
} | |
void OnGUI() { | |
// Something to do | |
// LOAD button | |
if (GUI.Button(new Rect(140, 30, 120, 60), "LOAD")) | |
{ | |
VAMPUnitySDK.load(); | |
} | |
// SHOW button | |
if (GUI.Button(new Rect(280, 30, 120, 60), "SHOW")) | |
{ | |
if (VAMPUnitySDK.isReady()) { | |
VAMPUnitySDK.show(); | |
} | |
} | |
} | |
/** | |
* 動画表示の準備完了 | |
*/ | |
void VAMPDidReceive(string str) { | |
Debug.Log("VAMPDidReceive"); | |
} | |
/** | |
* 動画準備or表示失敗 | |
*/ | |
void VAMPDidFail(string str) { | |
Debug.Log("VAMPDidFail"); | |
} | |
/** | |
* 動画再生正常終了(インセンティブ付与可能) | |
*/ | |
void VAMPDidComplete(string str) { | |
Debug.Log("VAMPDidComplete"); | |
} | |
/** | |
* 動画プレーヤーやエンドカードが表示終了 | |
* <注意:ユーザキャンセルなども含むので、インセンティブ付与はonCompleteで判定すること> | |
*/ | |
void VAMPDidClose(string str) { | |
Debug.Log("VAMPDidClose"); | |
} | |
/** | |
* 有効期限オーバー | |
* <注意:onReceiveを受けてからの有効期限が切れました。showするには再度loadを行う必要が有ります> | |
*/ | |
void VAMPDidExpired(string str) { | |
Debug.Log("VAMPDidExpired"); | |
} | |
/** | |
* 優先順位順にアドネットワークごとの広告取得を開始 | |
*/ | |
void VAMPLoadStart(string str) { | |
Debug.Log("VAMPLoadStart"); | |
} | |
/** | |
* アドネットワークごとの広告取得結果 | |
*/ | |
void VAMPLoadResult(string str) { | |
Debug.Log("VAMPLoadResult"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment