Commit 5f9c0410 authored by 王雪伟's avatar 王雪伟

加入Loading

parent e9460770
This diff is collapsed.
fileFormatVersion: 2
guid: 19cb369d889b04755a0562447e6cdc2e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MonoBaseMgr<T> : MonoBehaviour where T:MonoBehaviour
{
private static T instance;
public static T Getinstance()
{
if (instance==null)
{
GameObject obj = new GameObject(typeof(T).ToString() + "Scripts");
instance = obj.AddComponent<T>();
DontDestroyOnLoad(obj);
}
return instance;
}
public static T GetInstance()
{
if (instance == null)
{
GameObject obj = new GameObject(typeof(T).ToString() + "Scripts");
instance = obj.AddComponent<T>();
DontDestroyOnLoad(obj);
}
return instance;
}
public static T Instance()
{
if (instance == null)
{
GameObject obj = new GameObject(typeof(T).ToString() + "Scripts");
instance = obj.AddComponent<T>();
DontDestroyOnLoad(obj);
}
return instance;
}
}
fileFormatVersion: 2
guid: e8de3608ab9494f819f3c11756db1eff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class MonoMgr : MonoBaseMgr<MonoMgr>
{
public UnityAction func;
void Update()
{
func?.Invoke();
}
public void AddUpdateListener(UnityAction func)
{
this.func += func;
}
public void RemoveUpdateListener(UnityAction func)
{
this.func -= func;
}
}
......@@ -109,12 +109,10 @@ public class AdManager
#endif
break;
case ZXADConfig.PLANTFORM_AD_KUS:
#if UNITUY_ANDROD
if (id.codeAppId != null && id.codeAppId != "")
{
KsAdSDK.InitKsAdSDK(id.codeAppId,Application.identifier);
}
#endif
break;
default:
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "不支持初始化" + id.adPlatform + "的广告");
......@@ -1116,9 +1114,10 @@ public class AdManager
if (ADLoading.isShowing)
{
PlayCacheRewardVideoAd(ADLoading.adSlotName, ADLoading.adActionName, ADLoading.adListener);
ADLoading.Instance().HideADLoading();
PlayCacheRewardVideoAd(ADLoading.adSlotName, ADLoading.adActionName, ADLoading.adListener);
}
}
else
......@@ -1130,13 +1129,17 @@ public class AdManager
totalEntityList.RemoveAt(0);
mLoadRewardVideoAdPlatform(entity, rewardVideoAdCallBackA);
}
ADLoading.Instance().loadFailCount++;
if (ADLoading.Instance().loadFailCount == 2)
else
{
ADLoading.Instance().HideADLoading();
ADLoading.Instance().loadFailCount++;
if (ADLoading.Instance().loadFailCount == 2)
{
ADLoading.Instance().HideADLoading();
}
}
}
});
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "A开始缓存激励视频");
......@@ -1169,9 +1172,9 @@ public class AdManager
if (ADLoading.isShowing)
{
ADLoading.Instance().HideADLoading();
PlayCacheRewardVideoAd(ADLoading.adSlotName, ADLoading.adActionName, ADLoading.adListener);
ADLoading.Instance().HideADLoading();
}
}
else
......@@ -1183,13 +1186,17 @@ public class AdManager
totalEntityList.RemoveAt(0);
mLoadRewardVideoAdPlatform(entity, rewardVideoAdCallBackB);
}
ADLoading.Instance().loadFailCount++;
if (ADLoading.Instance().loadFailCount == 2)
else
{
ADLoading.Instance().HideADLoading();
ADLoading.Instance().loadFailCount++;
if (ADLoading.Instance().loadFailCount == 2)
{
ADLoading.Instance().HideADLoading();
}
}
}
});
Debug.unityLogger.Log(ZXADConfig.ADManagerTAG, "B开始缓存激励视频");
......@@ -1244,6 +1251,9 @@ public class AdManager
/// <param name="listener">广告回调</param>
public void PlayCacheRewardVideoAd(string slotName, string actionName, ZXADRewardVideoListener listener)
{
Debug.unityLogger.Log("1PlayCacheRewardVideoAd");
Debug.unityLogger.Log("2PlayCacheRewardVideoAd"+ slotName);
AdEntity entity = null;
AdEntity entityA = ZXADConfig.Instance.GetAdCache(slotName, "A");
......
......@@ -222,7 +222,10 @@ public class CSJSplshADUtils
EventUtils.onEventAdComplete(entity);
//listener.onAdSkip();
Debug.Log("splash Ad OnAdSkip");
#if UNITY_ANDROID
DestorySplash();
#endif
}
/// <summary>
......@@ -231,7 +234,9 @@ public class CSJSplshADUtils
public void OnAdTimeOver()
{
Debug.Log("splash Ad OnAdTimeOver");
#if UNITY_ANDROID
DestorySplash();
#endif
}
public void OnAdClose()
......
using System;
using System.Collections.Generic;
using UnityEngine;
public class AdUtils
{
private AdUtils() { }
private static readonly AdUtils singleInstance = new AdUtils();
public static AdUtils Instance
{
get
{
return singleInstance;
}
}
private void InitAd()
{
AdManager.Instance.InitAd(new Action<bool>((cb)=> {
if (cb)
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
}
}));
}
/// <summary>
/// 播放开屏广告
/// </summary>
public void ShowSplashAd(Action<bool> callback)
{
AdManager.Instance.LoadSplashAd(new SplshAdListener(callback));
}
/// <summary>
/// 播放激励视频广告
/// </summary>
public void ShowRewardAd(string action,Action<bool> callback)
{
AdManager.Instance.PlayCacheRewardVideoAd("video", "test", new RewardAdListener(callback));
}
private sealed class SplshAdListener : ZXADSplashListener
{
private Action<bool> callback;
public SplshAdListener(Action<bool> callback)
{
this.callback = callback;
}
public void onAdShow()
{
}
public void onAdSkip()
{
callback(true);
}
public void onError(string errorMsg)
{
}
public void onLastError()
{
callback(true);
}
}
public sealed class RewardAdListener : ZXADRewardVideoListener
{
private Action<bool> callback;
public RewardAdListener(Action<bool> callback)
{
this.callback = callback;
}
public void onAdClose(AdEntity entity)
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
callback(true);
}
public void onAdShow()
{
}
public void onAdVideoBarClick()
{
}
public void onError(string errorMsg)
{
AdManager.Instance.LoadCacheRewardVideoAd("video");
callback(false);
}
public void onSuccess()
{
}
}
}
fileFormatVersion: 2
guid: 7254c6703a47f6f438d80ec0dc944695
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -49,37 +49,42 @@ public class KsUnityFeedAd {
public void ShowFeedAd(Activity activity, KsUnityFeedShowListener listener) {
if (feedAd != null) {
feedAd.setAdInteractionListener(new KsFeedAd.AdInteractionListener() {
activity.runOnUiThread(new Runnable() {
@Override
public void onAdClicked() {
listener.onAdClicked();
}
public void run() {
feedAd.setAdInteractionListener(new KsFeedAd.AdInteractionListener() {
@Override
public void onAdClicked() {
listener.onAdClicked();
}
@Override
public void onAdShow() {
listener.onAdShow();
}
@Override
public void onAdShow() {
listener.onAdShow();
}
@Override
public void onDislikeClicked() {
removeAdView(activity, feedlinearLayout);
listener.onDislikeClicked();
@Override
public void onDislikeClicked() {
removeAdView(activity, feedlinearLayout);
listener.onDislikeClicked();
}
});
feedVidw = feedAd.getFeedView(activity);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.BOTTOM;
feedVidw.setLayoutParams(lp);
if (feedVidw != null) {
feedlinearLayout = new LinearLayout(activity);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
feedlinearLayout.setLayoutParams(layoutParams);
feedlinearLayout.addView(feedVidw);
ViewGroup root = getRootLayout(activity);
if (feedVidw != null) {
root.addView(feedlinearLayout);
}
}
}
});
feedVidw = feedAd.getFeedView(activity);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.BOTTOM;
feedVidw.setLayoutParams(lp);
if (feedVidw != null) {
feedlinearLayout = new LinearLayout(activity);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
feedlinearLayout.setLayoutParams(layoutParams);
feedlinearLayout.addView(feedVidw);
ViewGroup root = getRootLayout(activity);
if (feedVidw != null) {
root.addView(feedlinearLayout);
}
}
} else {
listener.onShowError(-1, "没有大图广告数据");
}
......
fileFormatVersion: 2
guid: 96eabe63e0a424642a928c97daa31a5f
MonoImporter:
guid: a7e20345cf807564fbfb4c3d2779e72f
folderAsset: yes
DefaultImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -192,7 +192,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 4283400949935885017}
- m_Target: {fileID: 0}
m_MethodName: HideADLoading
m_Mode: 1
m_Arguments:
......@@ -215,7 +215,6 @@ GameObject:
- component: {fileID: 7874596718903047866}
- component: {fileID: 7874596718903047867}
- component: {fileID: 7874596718903047812}
- component: {fileID: 4283400949935885017}
m_Layer: 5
m_Name: ADLoading
m_TagString: Untagged
......@@ -304,22 +303,6 @@ MonoBehaviour:
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &4283400949935885017
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7874596718903047813}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b8e186fde1a424d898d035bae5a45073, type: 3}
m_Name:
m_EditorClassIdentifier:
isShowing: 0
adSlotName:
adActionName:
loadFailCount: 0
--- !u!1 &7874596720360528070
GameObject:
m_ObjectHideFlags: 0
......
......@@ -11,7 +11,7 @@
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.uielements": "1.0.0"
},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.2d.common": {
"version": "2.1.0",
......@@ -21,21 +21,21 @@
"com.unity.2d.sprite": "1.0.0",
"com.unity.modules.uielements": "1.0.0"
},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.2d.path": {
"version": "2.1.0",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.2d.pixel-perfect": {
"version": "2.1.0",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.2d.psdimporter": {
"version": "2.1.6",
......@@ -46,7 +46,7 @@
"com.unity.2d.animation": "3.2.5",
"com.unity.2d.sprite": "1.0.0"
},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.2d.sprite": {
"version": "1.0.0",
......@@ -63,7 +63,7 @@
"com.unity.2d.common": "2.0.2",
"com.unity.2d.path": "2.0.6"
},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.2d.tilemap": {
"version": "1.0.0",
......@@ -76,14 +76,14 @@
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.ext.nunit": {
"version": "1.0.6",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.ide.rider": {
"version": "1.1.4",
......@@ -92,28 +92,28 @@
"dependencies": {
"com.unity.test-framework": "1.1.1"
},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.ide.vscode": {
"version": "1.2.3",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.mathematics": {
"version": "1.1.0",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.mobile.android-logcat": {
"version": "1.2.1",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.mobile.notifications": {
"version": "1.3.2",
......@@ -122,7 +122,7 @@
"dependencies": {
"com.unity.modules.androidjni": "1.0.0"
},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.test-framework": {
"version": "1.1.22",
......@@ -133,7 +133,7 @@
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.textmeshpro": {
"version": "2.1.3",
......@@ -142,7 +142,7 @@
"dependencies": {
"com.unity.ugui": "1.0.0"
},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.timeline": {
"version": "1.2.18",
......@@ -154,7 +154,7 @@
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0"
},
"url": "https://packages.unity.com"
"url": "https://packages.unity.cn"
},
"com.unity.ugui": {
"version": "1.0.0",
......
......@@ -39,6 +39,7 @@ GraphicsSettings:
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16003, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment