Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
W
wdlc_mjb_unity
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王雪伟
wdlc_mjb_unity
Commits
f531f188
Commit
f531f188
authored
Jun 22, 2021
by
zhangzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
穿山甲广告
parent
c4bc27cf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
361 additions
and
54 deletions
+361
-54
CSJFeedUtil.cs
Assets/Base/AdSDK/AD/CSJ/CSJFeedUtil.cs
+71
-6
Example.cs
Assets/Base/AdSDK/AD/CSJ/Example/Example.cs
+41
-19
Example.unity
Assets/Base/AdSDK/AD/CSJ/Example/Example.unity
+224
-9
InitScene.unity
Assets/Game/Main/Scenes/InitScene.unity
+1
-1
AdUtils.cs
Assets/Game/Main/Scripts/Utils/AdUtils.cs
+2
-2
DialogControl.cs
Assets/Game/Main/Scripts/View/DialogControl.cs
+9
-10
StickDialog.cs
Assets/Game/Main/Scripts/View/StickDialog.cs
+4
-4
EditorBuildSettings.asset
ProjectSettings/EditorBuildSettings.asset
+9
-3
No files found.
Assets/Base/AdSDK/AD/CSJ/CSJFeedUtil.cs
View file @
f531f188
...
@@ -49,8 +49,19 @@ public class CSJFeedUtil : MonoBehaviour
...
@@ -49,8 +49,19 @@ public class CSJFeedUtil : MonoBehaviour
#elif UNITY_IOS
#elif UNITY_IOS
feedAd
.
Dispose
();
feedAd
.
Dispose
();
feedAd
=
null
;
feedAd
=
null
;
#endif
if
(
lastEntity
!=
null
&&
lastCallBack
!=
null
)
{
var
adSlot
=
new
AdSlot
.
Builder
()
.
SetCodeId
(
lastEntity
.
codeId
)
.
SetImageAcceptedSize
(
Screen
.
width
,
0
)
.
SetSupportDeepLink
(
true
)
.
SetOrientation
(
AdOrientation
.
Horizontal
)
.
SetAdCount
(
1
)
//请求广告数量为1到3条
.
Build
();
this
.
AdNative
.
LoadNativeExpressAd
(
adSlot
,
new
CloseLoadFeedAdListener
(
lastEntity
,
lastCallBack
));
}
#endif
}
}
}
}
...
@@ -59,6 +70,9 @@ public class CSJFeedUtil : MonoBehaviour
...
@@ -59,6 +70,9 @@ public class CSJFeedUtil : MonoBehaviour
/// </summary>
/// </summary>
private
static
Queue
<
ExpressAd
>
feedAdCacheList
=
new
Queue
<
ExpressAd
>();
private
static
Queue
<
ExpressAd
>
feedAdCacheList
=
new
Queue
<
ExpressAd
>();
private
static
AdEntity
lastEntity
;
private
static
Action
<
bool
>
lastCallBack
;
/// <summary>
/// <summary>
/// 缓存加载FeedAd
/// 缓存加载FeedAd
/// </summary>
/// </summary>
...
@@ -66,17 +80,21 @@ public class CSJFeedUtil : MonoBehaviour
...
@@ -66,17 +80,21 @@ public class CSJFeedUtil : MonoBehaviour
/// <param name="callback"></param>
/// <param name="callback"></param>
public
void
LoadCacheFeedAd
(
AdEntity
entity
,
Action
<
bool
>
callback
)
public
void
LoadCacheFeedAd
(
AdEntity
entity
,
Action
<
bool
>
callback
)
{
{
lastEntity
=
entity
;
lastCallBack
=
callback
;
var
adSlot
=
new
AdSlot
.
Builder
()
var
adSlot
=
new
AdSlot
.
Builder
()
#if UNITY_IOS
#if UNITY_IOS
.
SetCodeId
(
entity
.
codeId
)
.
SetCodeId
(
entity
.
codeId
)
.
Set
ExpressView
AcceptedSize
(
Screen
.
width
,
0
)
.
Set
Image
AcceptedSize
(
Screen
.
width
,
0
)
#else
#else
.
SetCodeId
(
entity
.
codeId
)
.
SetCodeId
(
entity
.
codeId
)
////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应
////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应
.
SetExpressViewAcceptedSize
(
Screen
.
width
,
0
)
.
SetExpressViewAcceptedSize
(
Screen
.
width
,
0
)
.
SetImageAcceptedSize
(
1080
,
1920
)
#endif
#endif
.
SetSupportDeepLink
(
true
)
.
SetSupportDeepLink
(
true
)
.
SetImageAcceptedSize
(
1080
,
1920
)
.
SetOrientation
(
AdOrientation
.
Horizontal
)
.
SetOrientation
(
AdOrientation
.
Horizontal
)
.
SetAdCount
(
1
)
//请求广告数量为1到3条
.
SetAdCount
(
1
)
//请求广告数量为1到3条
.
Build
();
.
Build
();
...
@@ -85,19 +103,28 @@ public class CSJFeedUtil : MonoBehaviour
...
@@ -85,19 +103,28 @@ public class CSJFeedUtil : MonoBehaviour
//FeedAd IOS 和 Android 相同
//FeedAd IOS 和 Android 相同
private
ExpressAd
feedAd
;
private
ExpressAd
feedAd
;
// 判断是否是刘海屏
private
static
bool
isX
;
public
static
bool
IsX
{
get
=>
isX
=
!(
Screen
.
width
==
750
&&
Screen
.
height
==
1334
)
&&
!(
Screen
.
width
==
1242
&&
Screen
.
height
==
2208
)
&&
!(
Screen
.
width
==
640
&&
Screen
.
height
==
1136
)
&&
!(
Screen
.
width
==
1080
&&
Screen
.
height
==
1920
);
set
=>
isX
=
value
;
}
/// <summary>
/// <summary>
/// 展示缓存的FeedAd
/// 展示缓存的FeedAd
/// </summary>
/// </summary>
/// <param name="entity"></param>
/// <param name="entity"></param>
public
void
ShowCacheFeedAd
(
AdEntity
entity
,
Action
<
bool
>
callback
)
public
void
ShowCacheFeedAd
(
AdEntity
entity
,
Action
<
bool
>
callback
)
{
{
CloseFeedAd
();
//
CloseFeedAd();
if
(
feedAdCacheList
.
Count
>
0
)
if
(
feedAdCacheList
.
Count
>
0
)
{
{
feedAd
=
feedAdCacheList
.
Dequeue
();
feedAd
=
feedAdCacheList
.
Dequeue
();
#if UNITY_IOS
#if UNITY_IOS
in
t
x
=
0
;
floa
t
x
=
0
;
int
y
=
100
;
float
y
=
Screen
.
height
-
(
Screen
.
width
*
275.5f
/
375
)
-
(
IsX
?
45
:
0
)
;
//if (y == 0)
//if (y == 0)
//{
//{
// y = 100; // 防止Demo里刘海遮挡
// y = 100; // 防止Demo里刘海遮挡
...
@@ -162,6 +189,44 @@ public class CSJFeedUtil : MonoBehaviour
...
@@ -162,6 +189,44 @@ public class CSJFeedUtil : MonoBehaviour
}
}
/// <summary>
/// 代替关闭方法的加载方法监听
/// </summary>
private
sealed
class
CloseLoadFeedAdListener
:
IExpressAdListener
{
private
AdEntity
entity
;
private
Action
<
bool
>
callback
;
public
CloseLoadFeedAdListener
(
AdEntity
entity
,
Action
<
bool
>
callback
)
{
this
.
entity
=
entity
;
this
.
callback
=
callback
;
}
public
void
OnError
(
int
code
,
string
message
)
{
callback
(
false
);
}
public
void
OnExpressAdLoad
(
List
<
ExpressAd
>
ads
)
{
}
#if UNITY_IOS
public
void
OnExpressBannerAdLoad
(
ExpressBannerAd
ad
)
{
}
public
void
OnExpressInterstitialAdLoad
(
ExpressInterstitialAd
ad
)
{
}
#else
#endif
}
private
sealed
class
ExpressAdInteractionListener
:
IExpressAdInteractionListener
private
sealed
class
ExpressAdInteractionListener
:
IExpressAdInteractionListener
{
{
...
...
Assets/Base/AdSDK/AD/CSJ/Example/Example.cs
View file @
f531f188
...
@@ -726,22 +726,22 @@ public sealed class Example : MonoBehaviour
...
@@ -726,22 +726,22 @@ public sealed class Example : MonoBehaviour
public
void
LoadExpressFeedAd
()
public
void
LoadExpressFeedAd
()
{
{
//
this.width = GameObject.Find("Canvas/Width").GetComponent<InputField>();
this
.
width
=
GameObject
.
Find
(
"Canvas/Width"
).
GetComponent
<
InputField
>();
//
this.height = GameObject.Find("Canvas/Height").GetComponent<InputField>();
this
.
height
=
GameObject
.
Find
(
"Canvas/Height"
).
GetComponent
<
InputField
>();
//
int width;
int
width
;
//
int height;
int
height
;
//
int.TryParse(this.width.text, out width);
int
.
TryParse
(
this
.
width
.
text
,
out
width
);
//
int.TryParse(this.height.text, out height);
int
.
TryParse
(
this
.
height
.
text
,
out
height
);
//
if (width == 0)
if
(
width
==
0
)
//
{
{
// width = 375
;
width
=
Screen
.
width
;
//
}
}
//
if (height == 0)
if
(
height
==
0
)
//
{
{
//
height = 0;
height
=
0
;
//
}
}
#if UNITY_IOS
#if UNITY_IOS
...
@@ -760,14 +760,14 @@ public sealed class Example : MonoBehaviour
...
@@ -760,14 +760,14 @@ public sealed class Example : MonoBehaviour
var
adSlot
=
new
AdSlot
.
Builder
()
var
adSlot
=
new
AdSlot
.
Builder
()
#if UNITY_IOS
#if UNITY_IOS
.
SetCodeId
(
"945870984"
)
.
SetCodeId
(
"945870984"
)
.
Set
ExpressViewAcceptedSize
(
Screen
.
width
,
0
)
.
Set
ImageAcceptedSize
(
width
,
height
)
#else
#else
.
SetCodeId
(
"901121253"
)
.
SetCodeId
(
"901121253"
)
////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应
////期望模板广告view的size,单位dp,//高度设置为0,则高度会自适应
.
SetExpressViewAcceptedSize
(
350
,
0
)
.
SetExpressViewAcceptedSize
(
350
,
0
)
.
SetImageAcceptedSize
(
1080
,
1920
)
#endif
#endif
.
SetSupportDeepLink
(
true
)
.
SetSupportDeepLink
(
true
)
.
SetImageAcceptedSize
(
1080
,
1920
)
.
SetOrientation
(
AdOrientation
.
Horizontal
)
.
SetOrientation
(
AdOrientation
.
Horizontal
)
.
SetAdCount
(
1
)
//请求广告数量为1到3条
.
SetAdCount
(
1
)
//请求广告数量为1到3条
.
Build
();
.
Build
();
...
@@ -775,6 +775,25 @@ public sealed class Example : MonoBehaviour
...
@@ -775,6 +775,25 @@ public sealed class Example : MonoBehaviour
}
}
public
void
CloseExpressFeedAd
()
{
#if UNITY_IOS
if
(
this
.
mExpressFeedad
!=
null
)
{
this
.
mExpressFeedad
.
Dispose
();
this
.
mExpressFeedad
=
null
;
}
#endif
}
// 判断是否是刘海屏
private
static
bool
isX
;
public
static
bool
IsX
{
get
=>
isX
=
!(
Screen
.
width
==
750
&&
Screen
.
height
==
1334
)
&&
!(
Screen
.
width
==
1242
&&
Screen
.
height
==
2208
)
&&
!(
Screen
.
width
==
640
&&
Screen
.
height
==
1136
)
&&
!(
Screen
.
width
==
1080
&&
Screen
.
height
==
1920
);
set
=>
isX
=
value
;
}
/// <summary>
/// <summary>
/// Show the expressFeed Ad.
/// Show the expressFeed Ad.
/// </summary>
/// </summary>
...
@@ -800,10 +819,13 @@ public sealed class Example : MonoBehaviour
...
@@ -800,10 +819,13 @@ public sealed class Example : MonoBehaviour
if
(
y
==
0
)
if
(
y
==
0
)
{
{
y
=
100
;
// 防止Demo里刘海遮挡
this
.
mExpressFeedad
.
ShowExpressAd
(
x
,
Screen
.
height
-
(
Screen
.
width
*
275.5f
/
375
)
+
(
IsX
?
45
:
0
));
}
}
else
this
.
mExpressFeedad
.
ShowExpressAd
(
x
,
y
);
{
this
.
mExpressFeedad
.
ShowExpressAd
(
x
,
y
);
}
#else
#else
if
(
this
.
mExpressFeedad
==
null
)
if
(
this
.
mExpressFeedad
==
null
)
{
{
...
...
Assets/Base/AdSDK/AD/CSJ/Example/Example.unity
View file @
f531f188
This diff is collapsed.
Click to expand it.
Assets/Game/Main/Scenes/InitScene.unity
View file @
f531f188
...
@@ -382,7 +382,7 @@ MonoBehaviour:
...
@@ -382,7 +382,7 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
788e2a3a769e26b459cd63d4a5de7d76
,
type
:
3
}
m_Script
:
{
fileID
:
11500000
,
guid
:
788e2a3a769e26b459cd63d4a5de7d76
,
type
:
3
}
m_Name
:
m_Name
:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
isTest
:
0
isTest
:
1
isShowLog
:
1
isShowLog
:
1
XyDialog
:
{
fileID
:
0
}
XyDialog
:
{
fileID
:
0
}
---
!u!1
&2010092450
---
!u!1
&2010092450
...
...
Assets/Game/Main/Scripts/Utils/AdUtils.cs
View file @
f531f188
...
@@ -231,14 +231,14 @@ public class AdUtils
...
@@ -231,14 +231,14 @@ public class AdUtils
#endif
#endif
AdManager
.
Instance
.
CloseFeedAd
();
AdManager
.
Instance
.
CloseFeedAd
();
#if UNITY_IOS
#if UNITY_IOS
AdManager
.
Instance
.
LoadCacheFeedAd
(
"bigimage"
);
AdManager
.
Instance
.
LoadCacheFeedAd
(
"bigimage"
);
#endif
#endif
}
}
public
static
void
showBanner
(
string
action
)
public
static
void
showBanner
(
string
action
)
{
{
IsShowRewardAd
=
true
;
IsShowRewardAd
=
true
;
#if UNITY_EDITOR
#if UNITY_EDITOR
|| UNITY_IOS
return
;
return
;
#endif
#endif
AdManager
.
Instance
.
ShowCacheBannerAd
(
"banner"
,
action
);
AdManager
.
Instance
.
ShowCacheBannerAd
(
"banner"
,
action
);
...
...
Assets/Game/Main/Scripts/View/DialogControl.cs
View file @
f531f188
...
@@ -478,12 +478,12 @@ public class DialogControl : MonoBehaviour
...
@@ -478,12 +478,12 @@ public class DialogControl : MonoBehaviour
//EventUtils.OnEvent("addDiamond_click", "点击钻石加号");
//EventUtils.OnEvent("addDiamond_click", "点击钻石加号");
AudioUtils
.
ins
.
PlayBtnAudio
();
AudioUtils
.
ins
.
PlayBtnAudio
();
DiamondDialog
.
SetActive
(
true
);
DiamondDialog
.
SetActive
(
true
);
#if UNITY_IOS
//
#if UNITY_IOS
moveDiamondDialog
();
//
moveDiamondDialog();
#else
//
#else
Invoke
(
"showAd"
,
0.5f
);
Invoke
(
"showAd"
,
0.5f
);
Invoke
(
"moveDiamondDialog"
,
1f
);
Invoke
(
"moveDiamondDialog"
,
1f
);
#endif
//
#endif
HttpTool
.
Instance
.
_Get
(
"app/v1/wdlc/reward/diamond_by_video_status"
,
parm
,
new
Action
<
DiamondStatusBean
>((
bean
)
=>
HttpTool
.
Instance
.
_Get
(
"app/v1/wdlc/reward/diamond_by_video_status"
,
parm
,
new
Action
<
DiamondStatusBean
>((
bean
)
=>
{
{
...
@@ -587,12 +587,12 @@ public class DialogControl : MonoBehaviour
...
@@ -587,12 +587,12 @@ public class DialogControl : MonoBehaviour
AllSpeedDialog
.
SetActive
(
true
);
AllSpeedDialog
.
SetActive
(
true
);
allSpeedDesc
.
text
=
"所有作物成熟速度加"
+
bean
.
reduceMinute
+
"分钟"
;
allSpeedDesc
.
text
=
"所有作物成熟速度加"
+
bean
.
reduceMinute
+
"分钟"
;
useAllSpeedByVideoNumTv
.
text
=
"每天0点重置视频次数(剩余"
+
bean
.
todayVideoRemainingNum
+
"次)"
;
useAllSpeedByVideoNumTv
.
text
=
"每天0点重置视频次数(剩余"
+
bean
.
todayVideoRemainingNum
+
"次)"
;
#if UNITY_IOS
//
#if UNITY_IOS
moveAllSpeedDialog
();
//
moveAllSpeedDialog();
#else
//
#else
Invoke
(
"showAd"
,
0.5f
);
Invoke
(
"showAd"
,
0.5f
);
Invoke
(
"moveAllSpeedDialog"
,
1f
);
Invoke
(
"moveAllSpeedDialog"
,
1f
);
#endif
//
#endif
//HttpTool.Instance._Get("app/v1/game/reward_video/status", parm, new Action<VideoStatusBean>((bean) =>
//HttpTool.Instance._Get("app/v1/game/reward_video/status", parm, new Action<VideoStatusBean>((bean) =>
//{
//{
...
@@ -641,11 +641,10 @@ public class DialogControl : MonoBehaviour
...
@@ -641,11 +641,10 @@ public class DialogControl : MonoBehaviour
/// </summary>
/// </summary>
public
void
OnClickCloseAllSpeedDialog
()
public
void
OnClickCloseAllSpeedDialog
()
{
{
AdUtils
.
closeFeedAd
();
allspeedcontent
.
transform
.
localPosition
-=
new
Vector3
(
0
,
320
,
0
);
allspeedcontent
.
transform
.
localPosition
-=
new
Vector3
(
0
,
320
,
0
);
AudioUtils
.
ins
.
PlayBtnAudio
();
AudioUtils
.
ins
.
PlayBtnAudio
();
AllSpeedDialog
.
SetActive
(
false
);
AllSpeedDialog
.
SetActive
(
false
);
AdUtils
.
closeFeedAd
();
}
}
//使用及时雨
//使用及时雨
...
...
Assets/Game/Main/Scripts/View/StickDialog.cs
View file @
f531f188
...
@@ -34,12 +34,12 @@ public class StickDialog : MonoBehaviour
...
@@ -34,12 +34,12 @@ public class StickDialog : MonoBehaviour
Debug
.
unityLogger
.
Log
(
"显示害虫弹窗"
+
arg
);
Debug
.
unityLogger
.
Log
(
"显示害虫弹窗"
+
arg
);
StickDialogObj
.
SetActive
(
true
);
StickDialogObj
.
SetActive
(
true
);
#if UNITY_IOS
//
#if UNITY_IOS
moveDialog
();
//
moveDialog();
#else
//
#else
AdUtils
.
showFeedAd
(
"stick"
);
AdUtils
.
showFeedAd
(
"stick"
);
Invoke
(
"moveDialog"
,
1f
);
Invoke
(
"moveDialog"
,
1f
);
#endif
//
#endif
}
}
private
void
moveDialog
()
private
void
moveDialog
()
{
{
...
...
ProjectSettings/EditorBuildSettings.asset
View file @
f531f188
...
@@ -5,16 +5,22 @@ EditorBuildSettings:
...
@@ -5,16 +5,22 @@ EditorBuildSettings:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
serializedVersion
:
2
serializedVersion
:
2
m_Scenes
:
m_Scenes
:
-
enabled
:
1
-
enabled
:
0
path
:
Assets/Game/Main/Scenes/InitScene.unity
path
:
Assets/Game/Main/Scenes/InitScene.unity
guid
:
902436d14e36d4d42921eab701175b51
guid
:
902436d14e36d4d42921eab701175b51
-
enabled
:
1
-
enabled
:
0
path
:
Assets/Game/Splash/Splash.unity
path
:
Assets/Game/Splash/Splash.unity
guid
:
37af8cf3fb373478ab04e3ee2f3b700a
guid
:
37af8cf3fb373478ab04e3ee2f3b700a
-
enabled
:
1
-
enabled
:
0
path
:
Assets/Game/Main/Scenes/CrazyCar.unity
path
:
Assets/Game/Main/Scenes/CrazyCar.unity
guid
:
2ae344869669f6641a05481805b94e98
guid
:
2ae344869669f6641a05481805b94e98
-
enabled
:
0
-
enabled
:
0
path
:
Assets/Base/AdSDK/AD/Demo/AdDemo.unity
path
:
Assets/Base/AdSDK/AD/Demo/AdDemo.unity
guid
:
ef80a35d44f809e4a8957d1ed9571fd2
guid
:
ef80a35d44f809e4a8957d1ed9571fd2
-
enabled
:
0
path
:
Assets/Base/AdSDK/AD/CSJ/Example/Example.unity
guid
:
1e4f8457b1266154e80399e42b932ceb
-
enabled
:
1
path
:
Assets/Base/AdSDK/AD/GDT/UnionDemo/UnionExample.unity
guid
:
6c963ae210fa3c3438c2f6770ee81fc9
m_configObjects
:
{}
m_configObjects
:
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment