void Start() { titleflag = false; loadflag = false; m_status = 0; completeflag = false; // ~~~ VAMP初期化 ~~~ // trueを指定すると収益が発生しないテスト広告が配信されるようになります。 // ストアに申請する際は必ずfalseを設定してください VAMPUnitySDK.setTestMode(false); // trueを指定するとログを詳細に出力するデバッグモードになります VAMPUnitySDK.setDebugMode(false); // VAMPを初期化します。必ずLoadより先に実行してください VAMPUnitySDK.initialize(placementID); // リスナーを設定します VAMPUnitySDK.setVAMPListener(this); VAMPUnitySDK.setAdvancedListener(this); DontDestroyOnLoad(this); // 動画広告がまだ準備されていないときはロードを開始します VAMPUnitySDK.load(); }
void OnGUI() { GUIStyle btnStyle = GUI.skin.GetStyle("Button"); btnStyle.alignment = TextAnchor.MiddleCenter; btnStyle.fontSize = 30; GUIStyle labelStyle = GUI.skin.GetStyle("Label"); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.fontSize = 30; labelStyle.clipping = TextClipping.Overflow; GUIStyle textFStyle = GUI.skin.GetStyle("TextField"); textFStyle.alignment = TextAnchor.MiddleCenter; textFStyle.fontSize = 30; GUI.matrix = Matrix4x4.Scale(scaleV3); EdgeInsets safeAreaInsets = SDKTest.safeAreaInsets; if (blk == Block.Title) { logoCube.SetActive(false); labelStyle.fontSize = 25; GUI.Label(new Rect(0, height - 60 - safeAreaInsets.Bottom, width, 50), "APP " + appVersion + " / SDK " + sdkVersion); labelStyle.fontSize = 30; GUI.matrix = matrix; GUI.DrawTexture(new Rect(190, 490, 160, 160), logoTexture); labelStyle.alignment = TextAnchor.MiddleRight; // GUI.enabled = !isVampInitialized; GUI.Label(new Rect(100, 90, 80, 60), "ID:"); placementID = GUI.TextField(new Rect(200, 90, 240, 60), placementID); GUI.Label(new Rect(100, 170, 240, 60), "TestMode:"); if (GUI.Button(new Rect(350, 180, 40, 40), testMode ? btnOnTexture : btnOffTexture)) { testMode = !testMode; } GUI.Label(new Rect(100, 250, 240, 60), "DebugMode:"); if (GUI.Button(new Rect(350, 260, 40, 40), debugMode ? btnOnTexture : btnOffTexture)) { debugMode = !debugMode; } if (GUI.Button(new Rect(100, 330, 340, 60), "AD1")) { blk = Block.Ad1; isVampInitialized = true; // trueを指定すると収益が発生しないテスト広告が配信されるようになります。 // ストアに申請する際は必ずfalseを設定してください VAMPUnitySDK.setTestMode(testMode); // trueを指定するとログを詳細に出力するデバッグモードになります VAMPUnitySDK.setDebugMode(debugMode); // VAMPを初期化します。必ずLoadより先に実行してください VAMPUnitySDK.initialize(placementID); VAMPUnitySDK.setVAMPListener(this); VAMPUnitySDK.setAdvancedListener(this); } if (GUI.Button(new Rect(100, 410, 340, 60), "AD2")) { blk = Block.Ad2; isVampInitialized = true; // trueを指定すると収益が発生しないテスト広告が配信されるようになります。 // ストアに申請する際は必ずfalseを設定してください VAMPUnitySDK.setTestMode(testMode); // trueを指定するとログを詳細に出力するデバッグモードになります VAMPUnitySDK.setDebugMode(debugMode); // VAMPを初期化します。必ずLoadより先に実行してください VAMPUnitySDK.initialize(placementID); VAMPUnitySDK.setVAMPListener(this); VAMPUnitySDK.setAdvancedListener(this); // 広告のプリロードを開始します VAMPUnitySDK.preload(); } if (GUI.Button(new Rect(100, 490, 340, 60), "AD3")) { blk = Block.Ad3; isVampInitialized = true; // trueを指定すると収益が発生しないテスト広告が配信されるようになります。 // ストアに申請する際は必ずfalseを設定してください VAMPUnitySDK.setTestMode(testMode); // trueを指定するとログを詳細に出力するデバッグモードになります VAMPUnitySDK.setDebugMode(debugMode); // VAMPを初期化します。必ずLoadより先に実行してください VAMPUnitySDK.initialize(placementID); VAMPUnitySDK.setVAMPListener(this); VAMPUnitySDK.setAdvancedListener(this); } if (GUI.Button(new Rect(100, 570, 340, 60), "INFO")) { blk = Block.Info; // 国コード取得サンプル VAMPUnitySDK.getCountryCode((string countryCode) => { this.countryCode = countryCode; AddMessage(string.Format("CountryCode {0}", countryCode)); Debug.Log("[VAMPUnitySDK] VAMPCountryCode: " + countryCode); //if (countryCode == "US") { // // COPPA対象ユーザである場合はtrueを設定する // VAMPUnitySDK.setCoppaChildDirected(true); //} }); } } else if (blk == Block.Ad1) { logoCube.SetActive(true); if (GUI.Button(new Rect(0, 60 + safeAreaInsets.Top, 120, 60), "<戻る")) { blk = Block.Title; VAMPUnitySDK.clearLoaded(); isLoading = false; messages.Clear(); logPosition = Vector2.zero; } if (GUI.Button(new Rect(140, 60 + safeAreaInsets.Top, 120, 60), "LOAD")) { AddMessage("click load button."); // 動画広告ロードを開始します Debug.Log("[VAMPUnitySDK] VAMPUnitySDK.load()"); VAMPUnitySDK.load(); isLoading = true; } if (GUI.Button(new Rect(280, 60 + safeAreaInsets.Top, 120, 60), "SHOW")) { AddMessage("click show button."); // 動画広告が準備できているときは広告を表示します if (VAMPUnitySDK.isReady()) { Debug.Log("[VAMPUnitySDK] VAMPUnitySDK.show()"); VAMPUnitySDK.show(); } } labelStyle.fontSize = 25; GUI.Label(new Rect(0, 130 + safeAreaInsets.Top, width, 50), "[Test:" + testMode + "] [Debug:" + debugMode + "]"); GUI.Label(new Rect(0, 180 + safeAreaInsets.Top, width, 50), "ID:" + placementID); GUILayout.BeginArea(new Rect(20, 230 + safeAreaInsets.Top, width - 40, height - 190 - safeAreaInsets.Bottom)); logPosition = GUILayout.BeginScrollView(logPosition); labelStyle.alignment = TextAnchor.MiddleLeft; labelStyle.fontSize = 20; int count = 0; for (int i = messages.Count - 1; i >= 0; i--) { GUILayout.Label(messages[i], labelStyle); count++; if (count >= 200) { break; } } GUILayout.EndScrollView(); GUILayout.EndArea(); } else if (blk == Block.Ad2) { logoCube.SetActive(true); if (GUI.Button(new Rect(0, 60 + safeAreaInsets.Top, 120, 60), "<戻る")) { blk = Block.Title; VAMPUnitySDK.clearLoaded(); isLoading = false; messages.Clear(); logPosition = Vector2.zero; } if (GUI.Button(new Rect(140, 60 + safeAreaInsets.Top, 240, 60), "LOAD & SHOW")) { AddMessage("click load & show button."); if (!VAMPUnitySDK.isReady()) { // 動画広告ロードを開始します Debug.Log("[VAMPUnitySDK] VAMPUnitySDK.load()"); VAMPUnitySDK.load(); isLoading = true; } else { // 動画広告が準備できているときは広告を表示します Debug.Log("[VAMPUnitySDK] VAMPUnitySDK.show()"); VAMPUnitySDK.show(); } } labelStyle.fontSize = 25; GUI.Label(new Rect(0, 130 + safeAreaInsets.Top, width, 50), "[Test:" + testMode + "] [Debug:" + debugMode + "]"); GUI.Label(new Rect(0, 180 + safeAreaInsets.Top, width, 50), "ID:" + placementID); GUILayout.BeginArea(new Rect(20, 230 + safeAreaInsets.Top, width - 40, height - 190 - safeAreaInsets.Bottom)); logPosition = GUILayout.BeginScrollView(logPosition); labelStyle.alignment = TextAnchor.MiddleLeft; labelStyle.fontSize = 20; int count = 0; for (int i = messages.Count - 1; i >= 0; i--) { GUILayout.Label(messages[i], labelStyle); count++; if (count >= 200) { break; } } GUILayout.EndScrollView(); GUILayout.EndArea(); } else if (blk == Block.Ad3) { logoCube.SetActive(true); if (GUI.Button(new Rect(0, 60 + safeAreaInsets.Top, 120, 60), "<戻る")) { blk = Block.Title; VAMPUnitySDK.clearLoaded(); isLoading = false; messages.Clear(); logPosition = Vector2.zero; } if (GUI.Button(new Rect(140, 60 + safeAreaInsets.Top, 120, 60), "LOAD")) { AddMessage("click load button."); // 動画広告ロードを開始します Debug.Log("[VAMPUnitySDK] VAMPUnitySDK.load()"); VAMPUnitySDK.load(); isLoading = true; } if (GUI.Button(new Rect(280, 60 + safeAreaInsets.Top, 120, 60), "SHOW")) { AddMessage("click show button."); // 動画広告が準備できているときは広告を表示します if (VAMPUnitySDK.isReady()) { Debug.Log("[VAMPUnitySDK] VAMPUnitySDK.show()"); VAMPUnitySDK.show(); } } if (GUI.Button(new Rect(70, 130 + safeAreaInsets.Top, 400, 60), "SetFrequencyCap")) { AddMessage("click SetFrequencyCap button."); VAMPUnitySDK.setFrequencyCap(placementID, frequencyCap.impressions, frequencyCap.timeLimit); } if (GUI.Button(new Rect(70, 210 + safeAreaInsets.Top, 400, 60), "GetFrequencyCappedStatus")) { AddMessage("click GetFrequencyCappedStatus button."); using (var fpStatus = VAMPUnitySDK.getFrequencyCappedStatus(placementID)) { AddMessage(string.Format("capped:{0}, impressions:{1}, remainingTime:{2}, impressionLimit:{3}, timeLimit:{4}", fpStatus.IsCapped, fpStatus.Impressions, fpStatus.RemainingTime, fpStatus.ImpressionLimit, fpStatus.TimeLimit)); } } if (GUI.Button(new Rect(70, 290 + safeAreaInsets.Top, 400, 60), "ClearFrequencyCap")) { AddMessage("click clearFrequencyCap button"); VAMPUnitySDK.clearFrequencyCap(placementID); } if (GUI.Button(new Rect(70, 370 + safeAreaInsets.Top, 400, 60), "ResetFrequencyCap")) { AddMessage("click resetFrequencyCap button"); VAMPUnitySDK.resetFrequencyCap(placementID); } labelStyle.fontSize = 25; GUI.Label(new Rect(0, 450 + safeAreaInsets.Top, width, 50), "[Test:" + testMode + "] [Debug:" + debugMode + "]"); GUI.Label(new Rect(0, 500 + safeAreaInsets.Top, width, 50), "ID:" + placementID); GUILayout.BeginArea(new Rect(20, 550 + safeAreaInsets.Top, width - 40, height - 190 - safeAreaInsets.Bottom)); logPosition = GUILayout.BeginScrollView(logPosition); labelStyle.alignment = TextAnchor.MiddleLeft; labelStyle.fontSize = 20; int count = 0; for (int i = messages.Count - 1; i >= 0; i--) { GUILayout.Label(messages[i], labelStyle); count++; if (count >= 200) { break; } } GUILayout.EndScrollView(); GUILayout.EndArea(); } else if (blk == Block.Info) { logoCube.SetActive(false); if (GUI.Button(new Rect(0, 60 + safeAreaInsets.Top, 120, 60), "<戻る")) { blk = Block.Title; } GUILayout.BeginArea(new Rect(20, 130 + safeAreaInsets.Top, width - 40, height - 90 - safeAreaInsets.Bottom)); infoPosition = GUILayout.BeginScrollView(infoPosition); labelStyle.alignment = TextAnchor.MiddleLeft; labelStyle.fontSize = 20; for (int i = 0; i < infos.Count; i++) { GUILayout.Label(infos[i], labelStyle); } GUILayout.Label("Country Code:" + countryCode, labelStyle); GUILayout.EndScrollView(); GUILayout.EndArea(); } GUI.matrix = Matrix4x4.identity; GUI.skin = null; }
static public void Initialize() { VAMPUnitySDK.initialize(placementID); VAMPUnitySDK.load(); }