99jamin e0b73803a7 Do-37 [Feat] 보상형 전면 광고 추가
상점 패널의 첫 번째 요소를 광고 보상으로 설정하고, 클릭할 시 테스트 광고 실행 후 보상 함수 실행.
2025-03-17 16:58:31 +09:00

36 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ShopItemController : MonoBehaviour
{
ShopItem _shopItem;
public Sprite[] profileSprites;
public void Init(ShopItem shopItem)
{
_shopItem = shopItem;
var itemImage = GetComponentsInChildren<Image>()[1];
var itemText = GetComponentsInChildren<TextMeshProUGUI>();
itemImage.sprite = profileSprites[this._shopItem.ItemSpriteIndex];
itemText[0].text = this._shopItem.Name;
itemText[1].text = this._shopItem.Price;
}
public void OnClickShopItem()
{
Debug.Log(_shopItem.Name + "의 가격은" + _shopItem.Price);
if (_shopItem.Price == "광고") //첫번째 항목이 광고일 때를 가정하고 작성
{
Debug.Log("첫번쨰");
//보상형 전면 광고 로드
FindObjectOfType<AdManager>().ShowRewardedInterstitialAd(); //FindOf 함수는 추후 수정
}
}
}