質問編集履歴
5
エラーが出た時点のコードを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -274,7 +274,7 @@
|
|
274
274
|
|
275
275
|
// Called when an ad request failed to show.
|
276
276
|
|
277
|
-
this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
|
277
|
+
this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;//32行目
|
278
278
|
|
279
279
|
// Called when the user should be rewarded for interacting with the ad.
|
280
280
|
|
4
新しくエラーが出た時のスクリプトを追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -208,6 +208,176 @@
|
|
208
208
|
|
209
209
|
```
|
210
210
|
|
211
|
+
スクリプト
|
212
|
+
|
213
|
+
```C#
|
214
|
+
|
215
|
+
using UnityEngine.Events;
|
216
|
+
|
217
|
+
using UnityEngine;
|
218
|
+
|
219
|
+
using GoogleMobileAds.Api;
|
220
|
+
|
221
|
+
using GoogleMobileAds.Common;
|
222
|
+
|
223
|
+
using UnityEngine.UI;
|
224
|
+
|
225
|
+
using System;
|
226
|
+
|
227
|
+
using System.Collections.Generic;
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
public class Reward1 : MonoBehaviour
|
232
|
+
|
233
|
+
{
|
234
|
+
|
235
|
+
private RewardedAd rewardedAd;
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
public void Start()
|
240
|
+
|
241
|
+
{
|
242
|
+
|
243
|
+
string adUnitId;
|
244
|
+
|
245
|
+
#if UNITY_ANDROID
|
246
|
+
|
247
|
+
adUnitId = "ca-app-pub-3940256099942544/5224354917";
|
248
|
+
|
249
|
+
#elif UNITY_IPHONE
|
250
|
+
|
251
|
+
adUnitId = "ca-app-pub-3940256099942544/1712485313";
|
252
|
+
|
253
|
+
#else
|
254
|
+
|
255
|
+
adUnitId = "unexpected_platform";
|
256
|
+
|
257
|
+
#endif
|
258
|
+
|
259
|
+
this.rewardedAd = new RewardedAd(adUnitId);
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
// Called when an ad request has successfully loaded.
|
264
|
+
|
265
|
+
this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
|
266
|
+
|
267
|
+
// Called when an ad request failed to load.
|
268
|
+
|
269
|
+
this.rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
|
270
|
+
|
271
|
+
// Called when an ad is shown.
|
272
|
+
|
273
|
+
this.rewardedAd.OnAdOpening += HandleRewardedAdOpening;
|
274
|
+
|
275
|
+
// Called when an ad request failed to show.
|
276
|
+
|
277
|
+
this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
|
278
|
+
|
279
|
+
// Called when the user should be rewarded for interacting with the ad.
|
280
|
+
|
281
|
+
this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
|
282
|
+
|
283
|
+
// Called when the ad is closed.
|
284
|
+
|
285
|
+
this.rewardedAd.OnAdClosed += HandleRewardedAdClosed;
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
// Create an empty ad request.
|
290
|
+
|
291
|
+
AdRequest request = new AdRequest.Builder().Build();
|
292
|
+
|
293
|
+
// Load the rewarded ad with the request.
|
294
|
+
|
295
|
+
this.rewardedAd.LoadAd(request);
|
296
|
+
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
public void HandleRewardedAdLoaded(object sender, EventArgs args)
|
302
|
+
|
303
|
+
{
|
304
|
+
|
305
|
+
MonoBehaviour.print("HandleRewardedAdLoaded event received");
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
//AdErrorEventArgs
|
310
|
+
|
311
|
+
//AdFailedToLoadEventArgs
|
312
|
+
|
313
|
+
public void HandleRewardedAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
|
314
|
+
|
315
|
+
{
|
316
|
+
|
317
|
+
MonoBehaviour.print(
|
318
|
+
|
319
|
+
"HandleRewardedAdFailedToLoad event received with message: "
|
320
|
+
|
321
|
+
+ args.Message);
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
public void HandleRewardedAdOpening(object sender, EventArgs args)
|
328
|
+
|
329
|
+
{
|
330
|
+
|
331
|
+
MonoBehaviour.print("HandleRewardedAdOpening event received");
|
332
|
+
|
333
|
+
}
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
public void HandleRewardedAdFailedToShow(object sender, AdFailedToLoadEventArgs args)
|
338
|
+
|
339
|
+
{
|
340
|
+
|
341
|
+
MonoBehaviour.print(
|
342
|
+
|
343
|
+
"HandleRewardedAdFailedToShow event received with message: "
|
344
|
+
|
345
|
+
+ args.Message);
|
346
|
+
|
347
|
+
}
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
public void HandleRewardedAdClosed(object sender, EventArgs args)
|
352
|
+
|
353
|
+
{
|
354
|
+
|
355
|
+
MonoBehaviour.print("HandleRewardedAdClosed event received");
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
public void HandleUserEarnedReward(object sender, Reward args)
|
362
|
+
|
363
|
+
{
|
364
|
+
|
365
|
+
string type = args.Type;
|
366
|
+
|
367
|
+
double amount = args.Amount;
|
368
|
+
|
369
|
+
MonoBehaviour.print(
|
370
|
+
|
371
|
+
"HandleRewardedAdRewarded event received for "
|
372
|
+
|
373
|
+
+ amount.ToString() + " " + type);
|
374
|
+
|
375
|
+
}
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
```
|
380
|
+
|
211
381
|
試したこと
|
212
382
|
|
213
383
|
```
|
3
新たなエラーが出たので追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -186,7 +186,29 @@
|
|
186
186
|
|
187
187
|
```
|
188
188
|
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
追記
|
198
|
+
|
199
|
+
32行目にも同じようなエラーが出てしまいました。どのような引数の型を書けばエラーが発生されなくなりますか?
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
エラー
|
204
|
+
|
205
|
+
```
|
206
|
+
|
207
|
+
Assets/Scripts/Reward1.cs(32,9): error CS0123: デリゲート 'EventHandler<AdErrorEventArgs>' に一致する 'HandleRewardedAdFailedToShow' のオーバーロードはありません
|
208
|
+
|
209
|
+
```
|
210
|
+
|
189
|
-
試し
|
211
|
+
試したこと
|
190
212
|
|
191
213
|
```
|
192
214
|
|
@@ -194,4 +216,6 @@
|
|
194
216
|
|
195
217
|
・unityを再起動した
|
196
218
|
|
219
|
+
・HandleRewardedAdFailedToShowの引数の型をAdFailedToLoadEventArgsにもしてみましたがエラーが出ました
|
220
|
+
|
197
|
-
```
|
221
|
+
```
|
2
28行目の位置を修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -68,19 +68,19 @@
|
|
68
68
|
|
69
69
|
this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
|
70
70
|
|
71
|
+
|
72
|
+
|
73
|
+
//28行目
|
74
|
+
|
71
75
|
// Called when an ad request failed to load.
|
72
76
|
|
73
77
|
this.rewardedAd.OnAdFailedToLoad += HandleRewardedAdFailedToLoad;
|
74
78
|
|
75
79
|
|
76
80
|
|
77
|
-
//↓28行
|
78
|
-
|
79
81
|
// Called when an ad is shown.
|
80
82
|
|
81
83
|
this.rewardedAd.OnAdOpening += HandleRewardedAdOpening;
|
82
|
-
|
83
|
-
|
84
84
|
|
85
85
|
// Called when an ad request failed to show.
|
86
86
|
|
1
タイトルを変更しました
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
リワード広告
|
1
|
+
リワード広告で『デリゲート〜に一致する〜のオーバーロードはありません』というエラーが出ますがどのようなプログラムを書けば良いですか?
|
test
CHANGED
File without changes
|