Skip to content

Commit b167a2b

Browse files
committed
Release 1.6.0
1 parent 7396c59 commit b167a2b

25 files changed

+554
-313
lines changed

CHANGELOG.md

+28-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
Clever Ads Solutions Unity Plugin Change Log
22

3+
## [1.6.0] - 2020-10-07
4+
#### Dependencies
5+
- Wraps Android 1.6.2+ SDK
6+
- Wraps iOS 1.6.1+ SDK
7+
- External Dependency Manager for Unity 1.2.160
8+
#### Features
9+
- Support Unity 2019.3+. [New step to include Android](https://github.com/cleveradssolutions/CAS-Unity#support-of-unity-2019.3+) native platform.
10+
- Added settings to [redirect rewarded video ad impressions](https://github.com/cleveradssolutions/CAS-Unity#allow-interstitial-ads-when-video-cost-are-lower) to interstitial ads at higher cost per impression:
11+
```c#
12+
CAS.MobileAds.settings.allowInterstitialAdsWhenVideoCostAreLower = allow;
13+
```
14+
- Added [CAS Last Page Ad](https://github.com/cleveradssolutions/CAS-Unity#last-page-ad) to your own promotion when there is no paid ad to show or internet availability:
15+
```c#
16+
CAS.MobileAds.manager.lastPageAdContent = new LastPageAdContent(...);
17+
```
18+
- Added methods to get the current banner size in pixels:
19+
```c#
20+
float height = CAS.MobileAds.manager.GetBannerHeightInPixels();
21+
float width = CAS.MobileAds.manager.GetBannerWidthInPixels();
22+
```
23+
- Added more pre-build validation points to easily get a successful build.
24+
#### Bug Fixes
25+
- iOS platform Pause Unity Application while Ad impression
26+
327
## [1.5.0] - 2020-09-23
4-
Wraps Android 1.5.0 SDK
5-
Wraps iOS 1.5.2 SDK
6-
External Dependency Manager for Unity 1.2.159
28+
#### Dependencies
29+
- Wraps Android 1.5.0 SDK
30+
- Wraps iOS 1.5.2 SDK
31+
- External Dependency Manager for Unity 1.2.159

Editor/CASEditorUtils.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ internal static class CASEditorUtils
1616
public const string androidAdmobSampleAppID = "ca-app-pub-3940256099942544~3347511713";
1717
public const string iosAdmobSampleAppID = "ca-app-pub-3940256099942544~1458002511";
1818

19-
public const string editorRuntomeActiveAdPrefs = "typesadsavailable";
19+
public const string editorRuntimeActiveAdPrefs = "typesadsavailable";
20+
public const string editorReimportDepsOnBuildPrefs = "cas_reimport_deps_on_build";
2021
public const string rootCASFolderPath = "Assets/CleverAdsSolutions";
2122
public const string editorFolderPath = rootCASFolderPath + "/Editor";
2223
public const string androidLibFolderPath = "Assets/Plugins/Android/CASPlugin.androidlib";
@@ -41,6 +42,8 @@ internal static class CASEditorUtils
4142
public const string configuringPrivacyURL = "https://github.com/cleveradssolutions/CAS-iOS#step-5-configuring-privacy-controls";
4243

4344
public const string mainGradlePath = "Assets/Plugins/Android/mainTemplate.gradle";
45+
public const string launcherGradlePath = "Assets/Plugins/Android/launcherTemplate.gradle";
46+
public const string projectGradlePath = "Assets/Plugins/Android/baseProjectTemplate.gradle";
4447

4548
private const string locationUsageDefaultDescription = "Your data will be used to provide you a better and personalized ad experience.";
4649
#endregion
@@ -105,6 +108,7 @@ public static CASInitSettings GetSettingsAsset( BuildTarget platform )
105108
}
106109
else if (platform == BuildTarget.iOS)
107110
{
111+
asset.managerIds = new string[] { "" };
108112
asset.locationUsageDescription = locationUsageDefaultDescription;
109113
asset.interstitialInterval = 90;
110114
}
@@ -142,6 +146,18 @@ public static string GetTemplatePath( string templateFile )
142146
return path;
143147
}
144148

149+
public static bool TryActivateDependencies( string template, BuildTarget platform )
150+
{
151+
CreateFolderInAssets( "Editor" );
152+
153+
string fromPath = GetTemplatePath( template + platform.ToString() + ".xml" );
154+
if (string.IsNullOrEmpty( fromPath ))
155+
return false;
156+
157+
string dest = editorFolderPath + "/" + template + platform.ToString() + dependenciesExtension;
158+
return TryCopyFile( fromPath, dest );
159+
}
160+
145161
public static bool TryCopyFile( string source, string dest )
146162
{
147163
try

Editor/CASInitSettignsInspector.cs

+46-25
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using UnityEngine;
44
using UnityEditor;
5+
using UnityEditorInternal;
56

67
namespace CAS.UEditor
78
{
@@ -19,10 +20,12 @@ internal class CASInitSettignsInspector : Editor
1920
private SerializedProperty bannerSizeProp;
2021
private SerializedProperty locationUsageDescriptionProp;
2122

23+
private ReorderableList managerIdsList;
2224
private BuildTarget platform;
2325
private bool promoDependencyExist;
2426
private bool teenDependencyExist;
2527
private bool generalDependencyExist;
28+
private bool reimportDependencyOnBuild;
2629

2730
private int editorRuntimeActiveAdFlags;
2831
private Vector2 mediationNetworkScroll;
@@ -58,7 +61,8 @@ private void OnEnable()
5861
bannerSizeProp = props.FindProperty( "bannerSize" );
5962
locationUsageDescriptionProp = props.FindProperty( "locationUsageDescription" );
6063

61-
editorRuntimeActiveAdFlags = PlayerPrefs.GetInt( CASEditorUtils.editorRuntomeActiveAdPrefs, -1 );
64+
editorRuntimeActiveAdFlags = PlayerPrefs.GetInt( CASEditorUtils.editorRuntimeActiveAdPrefs, -1 );
65+
reimportDependencyOnBuild = PlayerPrefs.GetInt( CASEditorUtils.editorReimportDepsOnBuildPrefs, 1 ) == 1;
6266

6367
string assetName = target.name;
6468
if (assetName.EndsWith( BuildTarget.Android.ToString() ))
@@ -71,15 +75,36 @@ private void OnEnable()
7175
generalDependencyExist = CASEditorUtils.IsDependencyFileExists( CASEditorUtils.generalTemplateDependency, platform );
7276
teenDependencyExist = CASEditorUtils.IsDependencyFileExists( CASEditorUtils.teenTemplateDependency, platform );
7377
promoDependencyExist = CASEditorUtils.IsDependencyFileExists( CASEditorUtils.promoTemplateDependency, platform );
78+
79+
managerIdsList = new ReorderableList( props, managerIdsProp, true, true, true, true )
80+
{
81+
drawHeaderCallback = DrawListHeader,
82+
drawElementCallback = DrawListElement
83+
};
84+
}
85+
86+
private void DrawListHeader( Rect rect )
87+
{
88+
EditorGUI.LabelField( rect, "Manager ID's" );
7489
}
7590

91+
private void DrawListElement( Rect rect, int index, bool isActive, bool isFocused )
92+
{
93+
var item = managerIdsProp.GetArrayElementAtIndex( index );
94+
rect.yMin += 1;
95+
rect.yMax -= 1;
96+
item.stringValue = EditorGUI.TextField( rect, item.stringValue );
97+
}
98+
99+
76100
public override void OnInspectorGUI()
77101
{
78102
var obj = serializedObject;
79103
obj.UpdateIfRequiredOrScript();
80104
EditorGUILayout.PropertyField( testAdModeProp );
81105
EditorGUI.BeginDisabledGroup( testAdModeProp.boolValue );
82-
EditorGUILayout.PropertyField( managerIdsProp, true );
106+
DrawSeparator();
107+
managerIdsList.DoLayoutList();
83108
OnManagerIDVerificationGUI();
84109
EditorGUI.EndDisabledGroup();
85110

@@ -104,7 +129,7 @@ public override void OnInspectorGUI()
104129
DrawSeparator();
105130
interstitialIntervalProp.intValue = Math.Max( 0,
106131
EditorGUILayout.IntField( "Interstitial impression interval(sec):", interstitialIntervalProp.intValue ) );
107-
132+
108133
DrawSeparator();
109134
OnLoadingModeGUI();
110135
EditorGUILayout.PropertyField( debugModeProp );
@@ -116,6 +141,9 @@ public override void OnInspectorGUI()
116141
DrawSeparator();
117142
OnAllowedAdNetworksGUI();
118143

144+
DrawSeparator();
145+
OnBuildSettingsGUI();
146+
119147
DrawSeparator();
120148
OnCASAboutGUI();
121149
obj.ApplyModifiedProperties();
@@ -185,7 +213,7 @@ private bool OnAudienceGUIActiveChildren()
185213
"Please use Android Resolver after the change.",
186214
MessageType.Error );
187215
if (GUILayout.Button( "Activate", GUILayout.Height( 38 ) ))
188-
if (ActivateDependencies( CASEditorUtils.generalTemplateDependency ))
216+
if (CASEditorUtils.TryActivateDependencies( CASEditorUtils.generalTemplateDependency, platform ))
189217
generalDependencyExist = true;
190218
EditorGUILayout.EndHorizontal();
191219
}
@@ -226,7 +254,7 @@ private bool OnAudienceGUIActiveChildren()
226254
" require Teen CAS Dependencies to be activated. " +
227255
"Please use Android Resolver after the change.", MessageType.Error );
228256
if (GUILayout.Button( "Activate", GUILayout.Height( 38 ) ))
229-
if (ActivateDependencies( CASEditorUtils.teenTemplateDependency ))
257+
if (CASEditorUtils.TryActivateDependencies( CASEditorUtils.teenTemplateDependency, platform ))
230258
teenDependencyExist = true;
231259
EditorGUILayout.EndHorizontal();
232260
}
@@ -334,7 +362,7 @@ private void OnLoadingModeGUI()
334362
EditorGUI.EndDisabledGroup();
335363
}
336364

337-
private static void DrawEffectiveSlider( string label, float performVal )
365+
private void DrawEffectiveSlider( string label, float performVal )
338366
{
339367
EditorGUILayout.BeginHorizontal();
340368
GUILayout.Space( 15.0f );
@@ -354,11 +382,11 @@ private void OnEditroRuntimeActiveAdGUI()
354382
editorRuntimeActiveAdFlags = Convert.ToInt32(
355383
EditorGUILayout.EnumFlagsField( "Editor runtime Active ad", ( AdFlags )editorRuntimeActiveAdFlags ) );
356384
if (EditorGUI.EndChangeCheck())
357-
PlayerPrefs.SetInt( CASEditorUtils.editorRuntomeActiveAdPrefs, editorRuntimeActiveAdFlags );
385+
PlayerPrefs.SetInt( CASEditorUtils.editorRuntimeActiveAdPrefs, editorRuntimeActiveAdFlags );
358386
}
359387
}
360388

361-
private static void OnCASAboutGUI()
389+
private void OnCASAboutGUI()
362390
{
363391
EditorGUILayout.LabelField( "CAS Unity wrapper version: " + MobileAds.wrapperVersion );
364392
EditorGUILayout.BeginHorizontal();
@@ -382,24 +410,24 @@ private void OnPromoDependenciesGUI()
382410
}
383411
else
384412
{
385-
if (ActivateDependencies( CASEditorUtils.promoTemplateDependency ))
413+
if (CASEditorUtils.TryActivateDependencies( CASEditorUtils.promoTemplateDependency, platform ))
386414
promoDependencyExist = true;
387415
}
388416
}
389-
if(platform == BuildTarget.Android)
417+
if (platform == BuildTarget.Android)
390418
{
391419
EditorGUI.indentLevel++;
392420
EditorGUILayout.HelpBox( "Changing this flag will change the project dependencies. " +
393421
"Please use Android Resolver after the change.", MessageType.None );
394422
EditorGUI.indentLevel--;
395-
}
423+
}
396424
}
397425

398426
private void OnAllowedAdNetworksGUI()
399427
{
400428
var audience = ( Audience )audienceTaggedProp.enumValueIndex;
401429
mediationNetworkScroll = EditorGUILayout.BeginScrollView( mediationNetworkScroll,
402-
GUILayout.ExpandHeight( false ), GUILayout.MinHeight(EditorGUIUtility.singleLineHeight * 5.5f) );
430+
GUILayout.ExpandHeight( false ), GUILayout.MinHeight( EditorGUIUtility.singleLineHeight * 5.5f ) );
403431

404432
EditorGUILayout.LabelField( "Allowed partners networks for " + audience.ToString() + " audience" );
405433
EditorGUILayout.BeginHorizontal();
@@ -435,19 +463,13 @@ private void OnAllowedAdNetworksGUI()
435463
EditorGUILayout.EndScrollView();
436464
}
437465

438-
439-
440-
private bool ActivateDependencies( string template )
466+
private void OnBuildSettingsGUI()
441467
{
442-
CASEditorUtils.CreateFolderInAssets( "Editor" );
443-
444-
string fromPath = CASEditorUtils.GetTemplatePath( template + platform.ToString() + ".xml" );
445-
if (string.IsNullOrEmpty( fromPath ))
446-
return false;
447-
448-
string dest = CASEditorUtils.editorFolderPath + "/"
449-
+ template + platform.ToString() + CASEditorUtils.dependenciesExtension;
450-
return CASEditorUtils.TryCopyFile( fromPath, dest );
468+
if (reimportDependencyOnBuild != EditorGUILayout.ToggleLeft( "Force reimport CAS dependencies on build.", reimportDependencyOnBuild ))
469+
{
470+
reimportDependencyOnBuild = !reimportDependencyOnBuild;
471+
PlayerPrefs.SetInt( CASEditorUtils.editorReimportDepsOnBuildPrefs, reimportDependencyOnBuild ? 1 : 0 );
472+
}
451473
}
452474

453475
private bool DeactivateDependencies( string template )
@@ -456,7 +478,6 @@ private bool DeactivateDependencies( string template )
456478
+ template + platform.ToString() + CASEditorUtils.dependenciesExtension );
457479
}
458480

459-
460481
private struct PartnerNetwork
461482
{
462483
public readonly string name;

Editor/CASPostprocessBuild.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#if UNITY_IOS || CASDeveloper
22
using System;
33
using System.Collections.Generic;
4+
using System.Dynamic;
45
using System.IO;
56
using UnityEditor;
67
using UnityEditor.Callbacks;
@@ -161,9 +162,12 @@ private static void ApplyCrosspromoDynamicLinks( string projectPath )
161162
EditorUtility.DisplayProgressBar( casTitle, "Apply Crosspromo Dynamic Links", 0.9f );
162163
var identifier = Application.identifier;
163164
var productName = identifier.Substring( identifier.LastIndexOf( "." ) + 1 );
164-
165-
var entitlements = new ProjectCapabilityManager(
166-
projectPath, productName + ".entitlements", PBXProject.GetUnityTargetName() );
165+
#if UNITY_2019_3_OR_NEWER
166+
string target = null; // Use Default
167+
#else
168+
string target = PBXProject.GetUnityTargetName();
169+
#endif
170+
var entitlements = new ProjectCapabilityManager( projectPath, productName + ".entitlements", target );
167171

168172
var casSettings = CASEditorUtils.GetSettingsAsset( BuildTarget.iOS );
169173
var dynamicLinks = new List<string>( casSettings.managerIds.Length );

0 commit comments

Comments
 (0)