質問編集履歴
3
HandleRewardBasedVideoClosedのplayerHealth.Death();をコメントアウト
title
CHANGED
File without changes
|
body
CHANGED
@@ -118,8 +118,8 @@
|
|
118
118
|
|
119
119
|
public void HandleRewardBasedVideoClosed (object sender, EventArgs args)
|
120
120
|
{
|
121
|
-
// 追記
|
121
|
+
// 追記→コメントアウト
|
122
|
-
playerHealth.Death();
|
122
|
+
// playerHealth.Death();
|
123
123
|
MonoBehaviour.print ("HandleRewardBasedVideoClosed event received");
|
124
124
|
}
|
125
125
|
|
2
UniRx関連のコードを追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -26,6 +26,8 @@
|
|
26
26
|
using GoogleMobileAds.Api;
|
27
27
|
using System;
|
28
28
|
using StrOpe = StringOperationUtil.OptimizedStringOperation;
|
29
|
+
using UniRx;
|
30
|
+
using UniRx.Triggers;
|
29
31
|
|
30
32
|
public class AdManagement : MonoBehaviour {
|
31
33
|
|
@@ -38,6 +40,12 @@
|
|
38
40
|
this.rewardBasedVideo = RewardBasedVideoAd.Instance;
|
39
41
|
RequestRewardBasedVideo ();
|
40
42
|
RegistHandler ();
|
43
|
+
|
44
|
+
// 追記
|
45
|
+
this.UpdateAsObservable()
|
46
|
+
.Where(_ => endPlay)
|
47
|
+
.ObserveOnMainThread()
|
48
|
+
.Subscribe(_ => playerHealth.Revival());
|
41
49
|
}
|
42
50
|
|
43
51
|
private void RequestRewardBasedVideo()
|
@@ -99,8 +107,8 @@
|
|
99
107
|
// 広告動画が完全に視聴された際に呼び出されるメソッドと理解。キャラクターの体力を50%回復させたい
|
100
108
|
private void HandleRewardBasedVideoRewarded (object sender, Reward args)
|
101
109
|
{
|
102
|
-
//
|
110
|
+
// 追記
|
103
|
-
|
111
|
+
endPlay = true;
|
104
112
|
|
105
113
|
string type = args.Type;
|
106
114
|
double amount = args.Amount;
|
@@ -110,6 +118,8 @@
|
|
110
118
|
|
111
119
|
public void HandleRewardBasedVideoClosed (object sender, EventArgs args)
|
112
120
|
{
|
121
|
+
// 追記
|
122
|
+
playerHealth.Death();
|
113
123
|
MonoBehaviour.print ("HandleRewardBasedVideoClosed event received");
|
114
124
|
}
|
115
125
|
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -129,4 +129,7 @@
|
|
129
129
|
|
130
130
|
}
|
131
131
|
|
132
|
-
```
|
132
|
+
```
|
133
|
+
|
134
|
+
###参考にしたエントリ
|
135
|
+
[https://stackoverflow.com/questions/37354039/how-to-check-if-an-advertisement-has-finished-in-unity](https://stackoverflow.com/questions/37354039/how-to-check-if-an-advertisement-has-finished-in-unity)
|