diff --git a/CHANGELOG.md b/CHANGELOG.md index 2682080..3386e05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Clever Ads Solutions Unity Plugin Change Log +## [1.2.0] - 2021-03-02 +### Bug Fixes +- Fix `AppTrackingTransparency.Request()` in Unity Editor. + ## [1.2.0] - 2021-03-02 ### Dependencies - CleverAdsSolutions - [2.0.0](https://github.com/cleveradssolutions/CAS-Unity/releases) diff --git a/Editor/CASSimpleLocalizeTextEditor.cs b/Editor/CASSimpleLocalizeTextEditor.cs index 22999aa..73f8de5 100644 --- a/Editor/CASSimpleLocalizeTextEditor.cs +++ b/Editor/CASSimpleLocalizeTextEditor.cs @@ -1,7 +1,7 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; using UnityEditorInternal; using System; using CAS.UEditor; diff --git a/Editor/ConsentRequestParametersEditor.cs b/Editor/ConsentRequestParametersEditor.cs index 6238194..3ca2a5a 100644 --- a/Editor/ConsentRequestParametersEditor.cs +++ b/Editor/ConsentRequestParametersEditor.cs @@ -216,6 +216,7 @@ public static void CreateParameters() var togglePrefab = LoadUITemplatePrefab( templateSettingsPrefabName ); if (togglePrefab) asset.WithMediationSettingsTogglePrefab( togglePrefab.GetComponent() ); + AssetDatabase.CreateAsset( asset, assetPath ); } diff --git a/Editor/PostprocessiOSBuild.cs b/Editor/PostprocessiOSBuild.cs index f7335ac..af98af0 100644 --- a/Editor/PostprocessiOSBuild.cs +++ b/Editor/PostprocessiOSBuild.cs @@ -1,10 +1,10 @@ -#if UNITY_IOS || CASDeveloper +#if UNITY_IOS || CASDeveloper using System.IO; using UnityEditor; using UnityEditor.Callbacks; using UnityEditor.iOS.Xcode; -using UnityEngine; - +using UnityEngine; + namespace CAS.UserConsent { internal class PostprocessiOSBuild diff --git a/README.md b/README.md index 8c46522..a593c74 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Modify `Packages/manifest.json` to the following form: } ], "dependencies": { -"com.cleversolutions.ads.consent.unity": "https://github.com/cleveradssolutions/CAS-Unity-Consent.git#1.1.4" +"com.cleversolutions.ads.consent.unity": "https://github.com/cleveradssolutions/CAS-Unity-Consent.git#1.2.1" } } ``` diff --git a/Runtime/AppTrackingTransparency.cs b/Runtime/AppTrackingTransparency.cs index 7678494..8f0559a 100644 --- a/Runtime/AppTrackingTransparency.cs +++ b/Runtime/AppTrackingTransparency.cs @@ -52,8 +52,10 @@ public static void Request() if (string.IsNullOrEmpty( settings.defaultIOSTrakingUsageDescription )) throw new ArgumentNullException( "Please set NSUserTrackingUsageDescription in 'Assets > CleverAdsSolutions > Consent Request parameters' menu to correct tracking authorization request." ); -#endif + OnAuthorizationRequestComplete( Status.Authorized ); +#else CASURequestTracking( AuthorizationRequestComplete ); +#endif #else OnAuthorizationRequestComplete( Status.Authorized ); #endif diff --git a/Runtime/AudienceDefinitionUI.cs b/Runtime/AudienceDefinitionUI.cs index 356898a..5acf6e4 100644 --- a/Runtime/AudienceDefinitionUI.cs +++ b/Runtime/AudienceDefinitionUI.cs @@ -1,22 +1,22 @@ -using System; -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; -using UnityEngine; +using UnityEngine; using UnityEngine.Events; -using UnityEngine.UI; - -namespace CAS.UserConsent +using UnityEngine.UI; + +namespace CAS.UserConsent { - [AddComponentMenu( "CleverAdsSolutions/UserConsent/Audience Definition UI" )] - public sealed class AudienceDefinitionUI : MonoBehaviour - { - [Range( 0.05f, 1.0f )] + [AddComponentMenu( "CleverAdsSolutions/UserConsent/Audience Definition UI" )] + public sealed class AudienceDefinitionUI : MonoBehaviour + { + [Range( 0.05f, 1.0f )] [SerializeField] private float animationTime = 0.15f; [SerializeField] private int userInitialAge = 12; - [SerializeField] + [SerializeField] private List components = new List(); [Header( "Optional" )] @@ -24,53 +24,53 @@ public sealed class AudienceDefinitionUI : MonoBehaviour public UnityEvent OnConsentRequired; private Color selectedYearColor; - private Color defaultYearColor; - private Vector2[] textPositions; - private int currentYear; - private int selectedYear; - private int swipeProcess; - - private void Start() - { + private Color defaultYearColor; + private Vector2[] textPositions; + private int currentYear; + private int selectedYear; + private int swipeProcess; + + private void Start() + { if (components.Count == 5) { defaultYearColor = components[1].color; selectedYearColor = components[2].color; - } + } else { defaultYearColor = Color.clear; selectedYearColor = Color.clear; - } - currentYear = DateTime.Now.Year; + } + currentYear = DateTime.Now.Year; textPositions = new Vector2[components.Count]; - selectedYear = currentYear - userInitialAge; + selectedYear = currentYear - userInitialAge; for (int i = 0; i < components.Count; i++) { textPositions[i] = components[i].transform.position; components[i].text = ( selectedYear + 2 - i ).ToString(); } - SetTextColors(); - } - + SetTextColors(); + } + public void OnBeginIncreasingYear() { swipeProcess = 1; IncreaseYear(); - } - + } + public void OnEndIncreasingYear() { swipeProcess = 0; - } - + } + public void OnBeginDecreasingYear() { swipeProcess = -1; DecreaseYear(); - } - + } + public void OnEndDecreasingYear() { swipeProcess = 0; @@ -86,73 +86,73 @@ public void ApplySelectedYear() OnConsentRequired.Invoke(); } - private void DecreaseYear() - { - StopAllCoroutines(); - for (int i = 1; i < components.Count; i++) + private void DecreaseYear() + { + StopAllCoroutines(); + for (int i = 1; i < components.Count; i++) StartCoroutine( MoveTexts( components[i].transform, textPositions[i - 1] ) ); - selectedYear--; - var nextYear = selectedYear - 2; - Text text = components[0]; - text.transform.position = textPositions[textPositions.Length - 1]; - text.text = nextYear.ToString(); - components.Remove( text ); - components.Add( text ); - - SetTextColors(); - } - - private void IncreaseYear() - { - if (components[1].text == "") + selectedYear--; + var nextYear = selectedYear - 2; + Text text = components[0]; + text.transform.position = textPositions[textPositions.Length - 1]; + text.text = nextYear.ToString(); + components.Remove( text ); + components.Add( text ); + + SetTextColors(); + } + + private void IncreaseYear() + { + if (components[1].text == "") return; - StopAllCoroutines(); + StopAllCoroutines(); for (int i = 0; i < components.Count - 1; i++) StartCoroutine( MoveTexts( components[i].transform, textPositions[i + 1] ) ); selectedYear++; - var nextYear = selectedYear + 2; - - Text text = components[components.Count - 1]; - text.transform.position = textPositions[0]; - if (nextYear > currentYear) + var nextYear = selectedYear + 2; + + Text text = components[components.Count - 1]; + text.transform.position = textPositions[0]; + if (nextYear > currentYear) text.text = ""; else text.text = nextYear.ToString(); - components.Remove( text ); - components.Insert( 0, text ); - - SetTextColors(); + components.Remove( text ); + components.Insert( 0, text ); + + SetTextColors(); } - private void SetTextColors() + private void SetTextColors() { if (selectedYearColor == Color.clear) return; - for (int i = 0; i < components.Count; i++) - { + for (int i = 0; i < components.Count; i++) + { if (i == 2) components[i].color = selectedYearColor; - else - components[i].color = defaultYearColor; - } - } - - private IEnumerator MoveTexts( Transform moveText, Vector3 pos ) + else + components[i].color = defaultYearColor; + } + } + + private IEnumerator MoveTexts( Transform moveText, Vector3 pos ) { - float multiplier = 1f / animationTime * ( pos - moveText.position ).magnitude; - while (moveText.transform.position != pos) - { - moveText.position = Vector3.MoveTowards( moveText.position, pos, multiplier * Time.unscaledDeltaTime ); - yield return null; - } - if (swipeProcess < 0) - DecreaseYear(); - else if (swipeProcess > 0) - IncreaseYear(); - } - } -} + float multiplier = 1f / animationTime * ( pos - moveText.position ).magnitude; + while (moveText.transform.position != pos) + { + moveText.position = Vector3.MoveTowards( moveText.position, pos, multiplier * Time.unscaledDeltaTime ); + yield return null; + } + if (swipeProcess < 0) + DecreaseYear(); + else if (swipeProcess > 0) + IncreaseYear(); + } + } +} diff --git a/Runtime/CASSimpleLocalizeText.cs b/Runtime/CASSimpleLocalizeText.cs index 01cc10c..c25c2ca 100644 --- a/Runtime/CASSimpleLocalizeText.cs +++ b/Runtime/CASSimpleLocalizeText.cs @@ -1,8 +1,8 @@ -using System; -using UnityEngine; +using System; +using UnityEngine; using UnityEngine.Events; -using UnityEngine.UI; - +using UnityEngine.UI; + namespace CAS.UserConsent { [AddComponentMenu( "CleverAdsSolutions/UserConsent/CAS Simple Localize Text" )] @@ -31,4 +31,4 @@ private void Awake() UpdateString.Invoke( newText ); } } -} +} diff --git a/Runtime/ConsentRequestParameters.cs b/Runtime/ConsentRequestParameters.cs index 6940c2a..c7d1239 100644 --- a/Runtime/ConsentRequestParameters.cs +++ b/Runtime/ConsentRequestParameters.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -9,18 +9,18 @@ namespace CAS.UserConsent public sealed class ConsentRequestParameters : ScriptableObject { #region Fileds - public const string defaultAssetPath = "CASConsentRequestParameters"; - + public const string defaultAssetPath = "CASConsentRequestParameters"; + public Action OnConsent; -#pragma warning disable 649 // is never assigned to, and will always have its default value null - [SerializeField] - internal bool showInEditor = true; - [SerializeField] - internal bool withAudienceDefinition = true; - [SerializeField] - internal bool withDeclineOption = false; - [SerializeField] +#pragma warning disable 649 // is never assigned to, and will always have its default value null + [SerializeField] + internal bool showInEditor = true; + [SerializeField] + internal bool withAudienceDefinition = true; + [SerializeField] + internal bool withDeclineOption = false; + [SerializeField] internal bool withMediationSettings = true; [SerializeField] internal bool withRequestTrackingTransparency = false; diff --git a/Runtime/MediationSettingsUI.cs b/Runtime/MediationSettingsUI.cs index d89110c..b50db4e 100644 --- a/Runtime/MediationSettingsUI.cs +++ b/Runtime/MediationSettingsUI.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; diff --git a/Runtime/UserConsent.cs b/Runtime/UserConsent.cs index 0109920..c3ec358 100644 --- a/Runtime/UserConsent.cs +++ b/Runtime/UserConsent.cs @@ -5,7 +5,7 @@ namespace CAS.UserConsent { public static class UserConsent { - public const string version = "1.2.0"; + public const string version = "1.2.1"; /// /// User latest consent status values. diff --git a/Runtime/UserConsentUI.cs b/Runtime/UserConsentUI.cs index d43b584..56e9974 100644 --- a/Runtime/UserConsentUI.cs +++ b/Runtime/UserConsentUI.cs @@ -1,41 +1,41 @@ -using UnityEngine; +using UnityEngine; using UnityEngine.Events; -using UnityEngine.UI; - -namespace CAS.UserConsent -{ - [AddComponentMenu( "CleverAdsSolutions/UserConsent/Consent UI" )] - public sealed class UserConsentUI : MonoBehaviour +using UnityEngine.UI; + +namespace CAS.UserConsent +{ + [AddComponentMenu( "CleverAdsSolutions/UserConsent/Consent UI" )] + public sealed class UserConsentUI : MonoBehaviour { #pragma warning disable 0649 - [Header( "Panels" )] - [SerializeField] - private GameObject consentTextContainer; + [Header( "Panels" )] + [SerializeField] + private GameObject consentTextContainer; + [SerializeField] + private AudienceDefinitionUI audienceDefinition; [SerializeField] - private AudienceDefinitionUI audienceDefinition; - [SerializeField] private MediationSettingsUI mediationSettings; [Header( "Components" )] - [SerializeField] - private GameObject logoObj; - [SerializeField] - private Button privacyPolicyBtn; - [SerializeField] - private Button termsOfUseBtn; - - [Header( "Consent options" )] - [SerializeField] - private Button acceptBtn; - [SerializeField] - private Button declineBtn; - [SerializeField] + [SerializeField] + private GameObject logoObj; + [SerializeField] + private Button privacyPolicyBtn; + [SerializeField] + private Button termsOfUseBtn; + + [Header( "Consent options" )] + [SerializeField] + private Button acceptBtn; + [SerializeField] + private Button declineBtn; + [SerializeField] private Button mediationSettingsBtn; [Header( "Optional" )] public ConsentRequestParameters parameters; public UnityEvent onConsent; -#pragma warning restore 0649 +#pragma warning restore 0649 private void Awake() { @@ -43,8 +43,8 @@ private void Awake() if (parameters) Init( parameters ); - } - + } + public void Init( ConsentRequestParameters parameters ) { this.parameters = parameters; @@ -118,20 +118,20 @@ public void Init( ConsentRequestParameters parameters ) termsOfUseBtn.gameObject.SetActive( false ); } } - } - + } + private void OnOpenCompanyPrivacyPolicy() { Application.OpenURL( parameters.GetPrivacyPolicyUrl( Application.platform ) ); - } - + } + private void OnOpenTermsOfUse() { Application.OpenURL( parameters.GetTermsOfUseUrl( Application.platform ) ); - } - - private void ShowConsentPanel() - { + } + + private void ShowConsentPanel() + { if (parameters.withRequestTrackingTransparency) { CAS.iOS.AppTrackingTransparency.OnAuthorizationRequestComplete += ShowConsentContainer; @@ -140,22 +140,22 @@ private void ShowConsentPanel() else { consentTextContainer.SetActive( true ); - } - } - + } + } + private void ShowConsentContainer( iOS.AppTrackingTransparency.Status status ) { CAS.iOS.AppTrackingTransparency.OnAuthorizationRequestComplete -= ShowConsentContainer; consentTextContainer.SetActive( true ); - } - + } + private void OnOpenOptions() { logoObj.SetActive( false ); - consentTextContainer.SetActive( false ); + consentTextContainer.SetActive( false ); mediationSettings.gameObject.SetActive( true ); - } - + } + private void OnConsentAccepted() { consentTextContainer.SetActive( false ); @@ -167,8 +167,8 @@ private void OnConsentAccepted() if (parameters.OnConsent != null) parameters.OnConsent(); onConsent.Invoke(); - } - + } + private void OnConsentDenied() { consentTextContainer.SetActive( false ); @@ -180,14 +180,14 @@ private void OnConsentDenied() if (parameters.OnConsent != null) parameters.OnConsent(); onConsent.Invoke(); - } - + } + private void OnMediationSettingsApplied() { Destroy( gameObject ); if (parameters.OnConsent != null) parameters.OnConsent(); onConsent.Invoke(); - } - } -} + } + } +} diff --git a/package.json b/package.json index a81a4b7..4dd13fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.cleversolutions.ads.consent.unity", - "version": "1.2.0", + "version": "1.2.1", "displayName": "CleverAdsSolutions Consent", "description": "Clever Ads Solutions User consent Unity plugin.", "unity": "2017.4",