Do-37 [Feat] 보상형 전면 광고 추가
상점 패널의 첫 번째 요소를 광고 보상으로 설정하고, 클릭할 시 테스트 광고 실행 후 보상 함수 실행.
This commit is contained in:
parent
741064824c
commit
e0b73803a7
8
Assets/GoogleMobileAds/Resources.meta
Normal file
8
Assets/GoogleMobileAds/Resources.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f7ccc4a40ba9ce54eb682c4507bd9941
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -0,0 +1,22 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: a187246822bbb47529482707f3e0eff8, type: 3}
|
||||||
|
m_Name: GoogleMobileAdsSettings
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
adMobAndroidAppId: ca-app-pub-3940256099942544~3347511713
|
||||||
|
adMobIOSAppId: ca-app-pub-3940256099942544~1458002511
|
||||||
|
enableKotlinXCoroutinesPackagingOption: 1
|
||||||
|
optimizeInitialization: 0
|
||||||
|
optimizeAdLoading: 0
|
||||||
|
userTrackingUsageDescription:
|
||||||
|
validateGradleDependencies: 0
|
||||||
|
userLanguage: en
|
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f422e23084618ef4d88e27833b97e5f6
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
8
Assets/KJM/Admob.meta
Normal file
8
Assets/KJM/Admob.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 83ca459a697bf9c4d8d5050e5f7655e9
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
72
Assets/KJM/Admob/AdManager.cs
Normal file
72
Assets/KJM/Admob/AdManager.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using GoogleMobileAds.Api;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class AdManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
private RewardedInterstitialAd rewardedInterstitialAd;
|
||||||
|
private string adUnitId = "ca-app-pub-3940256099942544/5354046379"; // 테스트 광고 ID
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
// Google Mobile Ads 초기화
|
||||||
|
MobileAds.Initialize(initStatus => { Debug.Log("AdMob Initialized"); });
|
||||||
|
|
||||||
|
// 광고 로드
|
||||||
|
LoadRewardedInterstitialAd();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 보상형 전면 광고 로드
|
||||||
|
public void LoadRewardedInterstitialAd()
|
||||||
|
{
|
||||||
|
AdRequest request = new AdRequest();
|
||||||
|
|
||||||
|
RewardedInterstitialAd.Load(adUnitId, request,
|
||||||
|
(RewardedInterstitialAd ad, LoadAdError error) =>
|
||||||
|
{
|
||||||
|
if (error != null)
|
||||||
|
{
|
||||||
|
Debug.LogError("보상형 전면 광고 로드 실패: " + error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log("보상형 전면 광고 로드 성공");
|
||||||
|
rewardedInterstitialAd = ad;
|
||||||
|
|
||||||
|
// 광고 종료 이벤트 설정
|
||||||
|
rewardedInterstitialAd.OnAdFullScreenContentClosed += HandleAdClosed;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 보상형 전면 광고 실행
|
||||||
|
public void ShowRewardedInterstitialAd()
|
||||||
|
{
|
||||||
|
if (rewardedInterstitialAd != null && rewardedInterstitialAd.CanShowAd())
|
||||||
|
{
|
||||||
|
rewardedInterstitialAd.Show((Reward reward) =>
|
||||||
|
{
|
||||||
|
Debug.Log("코인 지급됨: " + reward.Amount);
|
||||||
|
// 코인 지급 로직
|
||||||
|
GrantReward();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("보상형 전면 광고가 아직 로드되지 않았습니다.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 광고 닫힘 이벤트 처리
|
||||||
|
private void HandleAdClosed()
|
||||||
|
{
|
||||||
|
Debug.Log("보상형 전면 광고 닫힘, 새로운 광고 로드.");
|
||||||
|
LoadRewardedInterstitialAd(); // 광고가 닫힌 후 다시 로드
|
||||||
|
}
|
||||||
|
|
||||||
|
// 코인 지급 함수
|
||||||
|
private void GrantReward()
|
||||||
|
{
|
||||||
|
Debug.Log("코인 지금 완료");
|
||||||
|
// 코인 보상 로직 추가
|
||||||
|
}
|
||||||
|
}
|
11
Assets/KJM/Admob/AdManager.cs.meta
Normal file
11
Assets/KJM/Admob/AdManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 644acbaf5d5791242b26c1b1b0a0ceeb
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
46
Assets/KJM/Admob/Admob.prefab
Normal file
46
Assets/KJM/Admob/Admob.prefab
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &8786799901643631561
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 7455536569977767830}
|
||||||
|
- component: {fileID: 2424336103342601865}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: Admob
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &7455536569977767830
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8786799901643631561}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &2424336103342601865
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8786799901643631561}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 644acbaf5d5791242b26c1b1b0a0ceeb, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
7
Assets/KJM/Admob/Admob.prefab.meta
Normal file
7
Assets/KJM/Admob/Admob.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c401513426cb83c4e8759c73d8be4c3a
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -491,5 +491,6 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 4d28917ad20c19e428cbf98ba5609e69, type: 3}
|
m_Script: {fileID: 11500000, guid: 4d28917ad20c19e428cbf98ba5609e69, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
adManager: {fileID: 8786799901643631561, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
profileSprites:
|
profileSprites:
|
||||||
- {fileID: 21300000, guid: 307bff9630735f342852f28b1cd5d300, type: 3}
|
- {fileID: 21300000, guid: 307bff9630735f342852f28b1cd5d300, type: 3}
|
||||||
|
@ -347,6 +347,63 @@ MonoBehaviour:
|
|||||||
m_DefaultSpriteDPI: 96
|
m_DefaultSpriteDPI: 96
|
||||||
m_DynamicPixelsPerUnit: 1
|
m_DynamicPixelsPerUnit: 1
|
||||||
m_PresetInfoIsWorld: 0
|
m_PresetInfoIsWorld: 0
|
||||||
|
--- !u!1001 &523594383261405864
|
||||||
|
PrefabInstance:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: 7455536569977767830, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7455536569977767830, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7455536569977767830, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7455536569977767830, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7455536569977767830, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7455536569977767830, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7455536569977767830, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7455536569977767830, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7455536569977767830, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.y
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7455536569977767830, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8786799901643631561, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
|
propertyPath: m_Name
|
||||||
|
value: Admob
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_RemovedGameObjects: []
|
||||||
|
m_AddedGameObjects: []
|
||||||
|
m_AddedComponents: []
|
||||||
|
m_SourcePrefab: {fileID: 100100000, guid: c401513426cb83c4e8759c73d8be4c3a, type: 3}
|
||||||
--- !u!1 &658145525140724706
|
--- !u!1 &658145525140724706
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -1690,3 +1747,4 @@ SceneRoots:
|
|||||||
- {fileID: 656468223}
|
- {fileID: 656468223}
|
||||||
- {fileID: 937655098394579964}
|
- {fileID: 937655098394579964}
|
||||||
- {fileID: 1842188762}
|
- {fileID: 1842188762}
|
||||||
|
- {fileID: 523594383261405864}
|
||||||
|
@ -6,6 +6,7 @@ using UnityEngine.UI;
|
|||||||
|
|
||||||
public class ShopItemController : MonoBehaviour
|
public class ShopItemController : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
ShopItem _shopItem;
|
ShopItem _shopItem;
|
||||||
public Sprite[] profileSprites;
|
public Sprite[] profileSprites;
|
||||||
|
|
||||||
@ -23,5 +24,12 @@ public class ShopItemController : MonoBehaviour
|
|||||||
public void OnClickShopItem()
|
public void OnClickShopItem()
|
||||||
{
|
{
|
||||||
Debug.Log(_shopItem.Name + "의 가격은" + _shopItem.Price);
|
Debug.Log(_shopItem.Name + "의 가격은" + _shopItem.Price);
|
||||||
|
|
||||||
|
if (_shopItem.Price == "광고") //첫번째 항목이 광고일 때를 가정하고 작성
|
||||||
|
{
|
||||||
|
Debug.Log("첫번쨰");
|
||||||
|
//보상형 전면 광고 로드
|
||||||
|
FindObjectOfType<AdManager>().ShowRewardedInterstitialAd(); //FindOf 함수는 추후 수정
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,20 +106,34 @@ public class TestPanelController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
|
|
||||||
List<ShopItem> shopItems = new List<ShopItem>(); //테스트 데이터 리스트 생성
|
List<ShopItem> shopItems = new List<ShopItem>(); //테스트 데이터 리스트 생성
|
||||||
for (int i = 0; i < 30; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
ShopItem shopItem = new ShopItem
|
if (i == 0) //광고 항목
|
||||||
{
|
{
|
||||||
ItemSpriteIndex = Random.Range(0, 1),
|
ShopItem shopItem = new ShopItem
|
||||||
Name = "코인"+i+"개",
|
{
|
||||||
Price = (i * 1000)+ "원"
|
ItemSpriteIndex = Random.Range(0, 1),
|
||||||
};
|
Name = "코인10개",
|
||||||
shopItems.Add(shopItem);
|
Price = "광고"
|
||||||
|
};
|
||||||
|
shopItems.Add(shopItem);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ShopItem shopItem = new ShopItem
|
||||||
|
{
|
||||||
|
ItemSpriteIndex = Random.Range(0, 1),
|
||||||
|
Name = "코인"+i+"개",
|
||||||
|
Price = (i * 1000)+ "원"
|
||||||
|
};
|
||||||
|
shopItems.Add(shopItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenShopPanel(shopItems);
|
OpenShopPanel(shopItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//기보 패널 생성
|
//기보 패널 생성
|
||||||
public void OnGiboPanelClick()
|
public void OnGiboPanelClick()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user