浏览代码

Banner Ads added

Testing adding banner ads to game
/AdsTesting
MrDonde 3 年前
当前提交
30b7b082
共有 9 个文件被更改,包括 90 次插入15 次删除
  1. 16
      Assets/Scenes/MainMenu.unity
  2. 2
      Assets/Scripts/GameManagerSO.cs
  3. 1
      Packages/manifest.json
  4. 9
      Packages/packages-lock.json
  5. 13
      ProjectSettings/ProjectSettings.asset
  6. 14
      ProjectSettings/UnityConnectSettings.asset
  7. 10
      UserSettings/EditorUserSettings.asset
  8. 29
      Assets/Scripts/BannerAds.cs
  9. 11
      Assets/Scripts/BannerAds.cs.meta

16
Assets/Scenes/MainMenu.unity


- component: {fileID: 1265336765}
- component: {fileID: 1265336764}
- component: {fileID: 1265336763}
- component: {fileID: 1265336766}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera

m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1265336766
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1265336762}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: db02582cda1704b4e99836f768d7b0ae, type: 3}
m_Name:
m_EditorClassIdentifier:
gameId: 4156920
placementId: Banner_Android
testMode: 1
--- !u!1 &1402112331
GameObject:
m_ObjectHideFlags: 0

2
Assets/Scripts/GameManagerSO.cs


{
Addressables.LoadSceneAsync("Store", UnityEngine.SceneManagement.LoadSceneMode.Single, true);
}
}
}

1
Packages/manifest.json


"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.addressables": "1.16.16",
"com.unity.ads": "3.7.1",
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.7",
"com.unity.postprocessing": "3.0.3",

9
Packages/packages-lock.json


},
"url": "https://packages.unity.com"
},
"com.unity.ads": {
"version": "3.7.1",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ugui": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.ext.nunit": {
"version": "1.0.6",
"depth": 1,

13
ProjectSettings/ProjectSettings.asset


XboxOneOverrideIdentityPublisher:
vrEditorSettings: {}
cloudServicesEnabled:
Analytics: 1
Build: 0
Collab: 0
Game Performance: 0
Purchasing: 0
UDP: 0
Unity Ads: 1
luminIcon:
m_Name:
m_ModelFolderPath:

m_VersionName:
apiCompatibilityLevel: 6
activeInputHandler: 0
cloudProjectId: ceded976-9f8b-45f6-9555-266c5abf1251
cloudProjectId: 8c4c76cf-e2a7-401a-9c86-8dfeae87fdef
projectName: Loady Dungeons
organizationId: unity-technologies-24112
projectName: Loady Dungeons (1)
organizationId: dondework
cloudEnabled: 0
legacyClampBlendShapeWeights: 0
virtualTexturingSupportEnabled: 0

14
ProjectSettings/UnityConnectSettings.asset


m_TestInitMode: 0
CrashReportingSettings:
m_EventUrl: https://perf-events.cloud.unity3d.com
m_Enabled: 1
m_Enabled: 0
m_LogBufferSize: 10
m_CaptureEditorExceptions: 1
UnityPurchasingSettings:

m_Enabled: 0
m_Enabled: 1
m_Enabled: 0
m_Enabled: 1
m_TestMode: 0
m_TestMode: 1
m_GameIds: {}
m_GameId:
m_GameIds:
AndroidPlayer: 4156920
iPhonePlayer: 4156921
m_GameId: 4156920
PerformanceReportingSettings:
m_Enabled: 0

10
UserSettings/EditorUserSettings.asset


value: 22424703114646680e0b0227036c731f171311242b1b2535232c5326ece92021
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c7315001214157c7868252320092a
value: 22424703114646680e0b0227036c7315001214157c7a68252320092a
value: 22424703114646680e0b0227036c7315001214157c7a68252320092a
value: 22424703114646680e0b0227036c7315001214157c7b68252320092a
value: 22424703114646680e0b0227036c7315001214157c7b68252320092a
value: 22424703114646680e0b0227036c6c0419051d6439262f2434
value: 22424703114646680e0b0227036c72111f19352f223d68252320092a
value: 22424703114646680e0b0227036c7315001214157c7868252320092a
value: 22424703114646680e0b0227036c6c0419051d6439262f2434
value: 22424703114646680e0b0227036c72111f19352f223d68252320092a
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650

29
Assets/Scripts/BannerAds.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class BannerAds : MonoBehaviour
{
public string gameId = "4156920";
public string placementId = "Banner_Android";
public bool testMode = true;
void Start()
{
// Initialize the SDK if you haven't already done so:
Advertisement.Initialize(gameId, testMode);
StartCoroutine(ShowBannerWhenReady());
}
IEnumerator ShowBannerWhenReady()
{
while (!Advertisement.IsReady(placementId))
{
yield return new WaitForSeconds(0.5f);
}
Advertisement.Banner.SetPosition(BannerPosition.TOP_CENTER);
Advertisement.Banner.Show(placementId);
}
}

11
Assets/Scripts/BannerAds.cs.meta


fileFormatVersion: 2
guid: db02582cda1704b4e99836f768d7b0ae
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存