我的项目中有两个场景。每个场景只有一个获奖视频。在第一个场景中,一切都很好,但是如果你从第二个场景到第一个场景,我不能给用户奖励,并且 endofRewarded 面板不可见。打赏的正确方法是什么?我怎样才能做到这一点?
Ps:我知道教程在这里。 https://developers.ironsrc.com/ironsource-mobile/unity/rewarded-video-integration-unity/
但是,我是初学者。谢谢你。
这是我的第一个场景的代码:
public class RewardedMain : MonoBehaviour
{
public string appkey;
public GameObject endofRewarded, anaEkran;
// Start is called before the first frame update
void Start()
{
IronSource.Agent.shouldTrackNetworkState(true);
IronSourceEvents.onRewardedVideoAvailabilityChangedEvent += RewardedVideoAvaibilityChangedEvent;
IronSourceEvents.onRewardedVideoAdClosedEvent += RewardedVideoAdClosedEvent;
IronSourceEvents.onRewardedVideoAdRewardedEvent += RewardedVideoAdRewardedEvent;
//IronSourceEvents.onRewardedVideoAdReadyEvent += OnRewardedVideoAdReady;
}//END START
public void showRewarded()
{
if (IronSource.Agent.isRewardedVideoAvailable())
{
anaEkran.SetActive(false);
IronSource.Agent.showRewardedVideo("MainRewarded");
}
}
void RewardedVideoAdClosedEvent()
{
IronSource.Agent.init(appkey, IronSourceAdUnits.REWARDED_VIDEO);
IronSource.Agent.shouldTrackNetworkState(true);
}
void RewardedVideoAvaibilityChangedEvent(bool available)
{
bool rewardedVideoAvailability = available;
}
void RewardedVideoAdRewardedEvent(IronSourcePlacement ssp)
{
PlayerPrefs.SetInt("totalCoin", PlayerPrefs.GetInt("totalCoin") + 150);
GameObject.Find("GoldNumberText").GetComponent<Text>().text = PlayerPrefs.GetInt("totalCoin").ToString();
SoundManager.Instance.PlayEarnGoldSound();
endofRewarded.SetActive(true);
}