diff --git a/README.md b/README.md index cb00411..f8e4230 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ ### 1: Download the repo and drop it into folder `Assets` ### 2: Add the line below to `Packages/manifest.json` -for version `3.2.4` +for version `3.2.5` ```csharp -"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.2.4", +"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.2.5", ``` ## Includes modules diff --git a/VirtueSky/Advertising/Runtime/Admob/AdmobAdClient.cs b/VirtueSky/Advertising/Runtime/Admob/AdmobAdClient.cs index 6d9f5e9..8cdd245 100644 --- a/VirtueSky/Advertising/Runtime/Admob/AdmobAdClient.cs +++ b/VirtueSky/Advertising/Runtime/Admob/AdmobAdClient.cs @@ -42,9 +42,11 @@ public override void Initialize() LoadRewarded(); LoadRewardedInterstitial(); LoadAppOpen(); + LoadBanner(); #endif } + #if VIRTUESKY_ADS && VIRTUESKY_ADMOB void RegisterAppStateChange() { @@ -60,5 +62,40 @@ void OnAppStateChanged(GoogleMobileAds.Common.AppState state) } } #endif + public override void LoadBanner() + { + if (adSetting.AdmobBannerVariable == null) return; + adSetting.AdmobBannerVariable.Load(); + } + + public override void LoadInterstitial() + { + if (adSetting.AdmobInterVariable == null) return; + if (!adSetting.AdmobInterVariable.IsReady()) adSetting.AdmobInterVariable.Load(); + } + + public override void LoadRewarded() + { + if (adSetting.AdmobRewardVariable == null) return; + if (!adSetting.AdmobRewardVariable.IsReady()) adSetting.AdmobRewardVariable.Load(); + } + + public override void LoadRewardedInterstitial() + { + if (adSetting.AdmobRewardInterVariable == null) return; + if (!adSetting.AdmobRewardInterVariable.IsReady()) adSetting.AdmobRewardInterVariable.Load(); + } + + public override void LoadAppOpen() + { + if (adSetting.AdmobAppOpenVariable == null) return; + if (!adSetting.AdmobAppOpenVariable.IsReady()) adSetting.AdmobAppOpenVariable.Load(); + } + + public override void ShowAppOpen() + { + if (statusAppOpenFirstIgnore) adSetting.AdmobAppOpenVariable.Show(); + statusAppOpenFirstIgnore = true; + } } } \ No newline at end of file diff --git a/VirtueSky/Advertising/Runtime/General/AdClient.cs b/VirtueSky/Advertising/Runtime/General/AdClient.cs index 82a158a..42109ed 100644 --- a/VirtueSky/Advertising/Runtime/General/AdClient.cs +++ b/VirtueSky/Advertising/Runtime/General/AdClient.cs @@ -1,12 +1,9 @@ -using UnityEngine; -using VirtueSky.Inspector; - namespace VirtueSky.Ads { public abstract class AdClient { protected AdSetting adSetting; - private bool _statusAppOpenFirstIgnore; + protected bool statusAppOpenFirstIgnore; public void SetupAdSetting(AdSetting _adSetting) { @@ -14,111 +11,11 @@ public void SetupAdSetting(AdSetting _adSetting) } public abstract void Initialize(); - - #region Inter Ad - - private AdUnitVariable InterstitialAdUnit() - { - return adSetting.CurrentAdNetwork switch - { - AdNetwork.Max => adSetting.MaxInterVariable, - AdNetwork.Admob => adSetting.AdmobInterVariable, - _ => adSetting.IronSourceInterVariable, - }; - } - - protected virtual bool IsInterstitialReady() - { - return InterstitialAdUnit().IsReady(); - } - - public virtual void LoadInterstitial() - { - if (InterstitialAdUnit() == null) return; - if (!IsInterstitialReady()) InterstitialAdUnit().Load(); - } - - #endregion - - #region Reward Ad - - private AdUnitVariable RewardAdUnit() - { - return adSetting.CurrentAdNetwork switch - { - AdNetwork.Max => adSetting.MaxRewardVariable, - AdNetwork.Admob => adSetting.AdmobRewardVariable, - _ => adSetting.IronSourceRewardVariable, - }; - } - - protected virtual bool IsRewardedReady() - { - return RewardAdUnit().IsReady(); - } - - public virtual void LoadRewarded() - { - if (RewardAdUnit() == null) return; - if (!IsRewardedReady()) RewardAdUnit().Load(); - } - - #endregion - - #region Reward Inter Ad - - private AdUnitVariable RewardedInterstitialAdUnit() - { - return adSetting.CurrentAdNetwork switch - { - AdNetwork.Max => adSetting.MaxRewardInterVariable, - AdNetwork.Admob => adSetting.AdmobRewardInterVariable, - _ => null, - }; - } - - protected virtual bool IsRewardedInterstitialReady() - { - return RewardedInterstitialAdUnit().IsReady(); - } - - public virtual void LoadRewardedInterstitial() - { - if (RewardedInterstitialAdUnit() == null) return; - if (!IsRewardedInterstitialReady()) RewardedInterstitialAdUnit().Load(); - } - - #endregion - - #region AppOpen Ad - - private AdUnitVariable AppOpenAdUnit() - { - return adSetting.CurrentAdNetwork switch - { - AdNetwork.Max => adSetting.MaxAppOpenVariable, - AdNetwork.Admob => adSetting.AdmobAppOpenVariable, - _ => null - }; - } - - protected virtual bool IsAppOpenReady() - { - return AppOpenAdUnit().IsReady(); - } - - public virtual void LoadAppOpen() - { - if (AppOpenAdUnit() == null) return; - if (!IsAppOpenReady()) AppOpenAdUnit().Load(); - } - - public virtual void ShowAppOpen() - { - if (_statusAppOpenFirstIgnore) AppOpenAdUnit().Show(); - _statusAppOpenFirstIgnore = true; - } - - #endregion + public abstract void LoadBanner(); + public abstract void LoadInterstitial(); + public abstract void LoadRewarded(); + public abstract void LoadRewardedInterstitial(); + public abstract void LoadAppOpen(); + public abstract void ShowAppOpen(); } } \ No newline at end of file diff --git a/VirtueSky/Advertising/Runtime/IronSource/IronSourceAdClient.cs b/VirtueSky/Advertising/Runtime/IronSource/IronSourceAdClient.cs index c4e1f46..8db8aa2 100644 --- a/VirtueSky/Advertising/Runtime/IronSource/IronSourceAdClient.cs +++ b/VirtueSky/Advertising/Runtime/IronSource/IronSourceAdClient.cs @@ -1,4 +1,3 @@ -using UnityEngine; using VirtueSky.Core; using VirtueSky.Tracking; @@ -7,6 +6,7 @@ namespace VirtueSky.Ads public class IronSourceAdClient : AdClient { public bool SdkInitializationCompleted { get; private set; } + public override void Initialize() { SdkInitializationCompleted = false; @@ -27,7 +27,9 @@ public override void Initialize() #endif LoadInterstitial(); LoadRewarded(); + LoadBanner(); } + #if VIRTUESKY_ADS && VIRTUESKY_IRONSOURCE private void ImpressionDataReadyEvent(IronSourceImpressionData impressionData) { @@ -48,5 +50,35 @@ void SdkInitializationCompletedEvent() { SdkInitializationCompleted = true; } + + public override void LoadBanner() + { + if (adSetting.IronSourceBannerVariable == null) return; + adSetting.IronSourceBannerVariable.Load(); + } + + public override void LoadInterstitial() + { + if (adSetting.IronSourceInterVariable == null) return; + if (!adSetting.IronSourceInterVariable.IsReady()) adSetting.IronSourceInterVariable.Load(); + } + + public override void LoadRewarded() + { + if (adSetting.IronSourceRewardVariable == null) return; + if (!adSetting.IronSourceRewardVariable.IsReady()) adSetting.IronSourceRewardVariable.Load(); + } + + public override void LoadRewardedInterstitial() + { + } + + public override void LoadAppOpen() + { + } + + public override void ShowAppOpen() + { + } } } \ No newline at end of file diff --git a/VirtueSky/Advertising/Runtime/Max/MaxAdClient.cs b/VirtueSky/Advertising/Runtime/Max/MaxAdClient.cs index 9468c13..02c46e0 100644 --- a/VirtueSky/Advertising/Runtime/Max/MaxAdClient.cs +++ b/VirtueSky/Advertising/Runtime/Max/MaxAdClient.cs @@ -1,4 +1,3 @@ -using UnityEngine; using VirtueSky.Core; namespace VirtueSky.Ads @@ -20,9 +19,11 @@ public override void Initialize() LoadRewarded(); LoadRewardedInterstitial(); LoadAppOpen(); + LoadBanner(); #endif } + #if VIRTUESKY_ADS && VIRTUESKY_APPLOVIN private void OnAppStateChange(bool pauseStatus) { @@ -32,5 +33,41 @@ private void OnAppStateChange(bool pauseStatus) } } #endif + + public override void LoadBanner() + { + if (adSetting.MaxBannerVariable == null) return; + adSetting.MaxBannerVariable.Load(); + } + + public override void LoadInterstitial() + { + if (adSetting.MaxInterVariable == null) return; + if (!adSetting.MaxInterVariable.IsReady()) adSetting.MaxInterVariable.Load(); + } + + public override void LoadRewarded() + { + if (adSetting.MaxRewardVariable == null) return; + if (!adSetting.MaxRewardVariable.IsReady()) adSetting.MaxRewardVariable.Load(); + } + + public override void LoadRewardedInterstitial() + { + if (adSetting.MaxRewardInterVariable == null) return; + if (!adSetting.MaxRewardInterVariable.IsReady()) adSetting.MaxRewardInterVariable.Load(); + } + + public override void LoadAppOpen() + { + if (adSetting.MaxAppOpenVariable == null) return; + if (!adSetting.MaxAppOpenVariable.IsReady()) adSetting.MaxAppOpenVariable.Load(); + } + + public override void ShowAppOpen() + { + if (statusAppOpenFirstIgnore) adSetting.MaxAppOpenVariable.Show(); + statusAppOpenFirstIgnore = true; + } } } \ No newline at end of file diff --git a/VirtueSky/ControlPanel/ConstantPackage.cs b/VirtueSky/ControlPanel/ConstantPackage.cs index cc02191..97776dd 100644 --- a/VirtueSky/ControlPanel/ConstantPackage.cs +++ b/VirtueSky/ControlPanel/ConstantPackage.cs @@ -2,7 +2,7 @@ { public class ConstantPackage { - public const string VersionSunflower = "3.2.4"; + public const string VersionSunflower = "3.2.5"; public const string PackageNameInAppPurchase = "com.unity.purchasing"; public const string MaxVersionInAppPurchase = "4.12.2"; public const string PackageNameNewtonsoftJson = "com.unity.nuget.newtonsoft-json"; @@ -97,18 +97,16 @@ public class ConstantPackage public const string PackageNameCoffeeUIEffect = "com.coffee.ui-effect"; public const string MaxVersionCoffeeUIEffect = - "https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.0.1"; + "https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.0.2"; public const string PackageNameCoffeeUIParticle = "com.coffee.ui-particle"; public const string MaxVersionCoffeeUIParticle = - "https://github.com/mob-sakai/ParticleEffectForUGUI.git#4.10.3"; + "https://github.com/mob-sakai/ParticleEffectForUGUI.git#4.10.5"; public const string PackageNameAppleSignIn = "com.lupidan.apple-signin-unity"; public const string MaxVersionAppleSignIn = "https://github.com/lupidan/apple-signin-unity.git#v1.4.3"; - //public const string PackageNameAnimancer = "com.virtuesky.animancer"; - //public const string MaxVersionAnimancer = "https://github.com/VirtueSky/animancer-unity.git#7.0.0"; #region Spine diff --git a/VirtueSky/Iap/Runtime/IapDataVariable.cs b/VirtueSky/Iap/Runtime/IapDataVariable.cs index ea0e6f7..8ae6a96 100644 --- a/VirtueSky/Iap/Runtime/IapDataVariable.cs +++ b/VirtueSky/Iap/Runtime/IapDataVariable.cs @@ -15,7 +15,9 @@ public class IapDataVariable : ScriptableObject [ReadOnly] public string id; [ReadOnly] public ProductType productType; - [Space] public float price; + [Tooltip("Price config used for UI"), Space] + public float priceConfig; + [SerializeField] private IapPurchaseSuccess onPurchaseSuccess; [SerializeField] private IapPurchaseFailed onPurchaseFailed; internal IapPurchaseSuccess OnPurchaseSuccess => onPurchaseSuccess; @@ -54,6 +56,36 @@ public bool IsPurchased() if (iapManager == null) return false; return iapManager.IsPurchasedProduct(this); } + + public string GetLocalizedPriceString() + { + if (GetProduct() == null) return String.Empty; + return GetProduct().metadata.localizedPriceString; + } + + public string GetIsoCurrencyCode() + { + if (GetProduct() == null) return String.Empty; + return GetProduct().metadata.isoCurrencyCode; + } + + public string GetLocalizedDescription() + { + if (GetProduct() == null) return String.Empty; + return GetProduct().metadata.localizedDescription; + } + + public string GetLocalizedTitle() + { + if (GetProduct() == null) return String.Empty; + return GetProduct().metadata.localizedTitle; + } + + public decimal GetLocalizedPrice() + { + if (GetProduct() == null) return 0; + return GetProduct().metadata.localizedPrice; + } } } #endif \ No newline at end of file diff --git a/package.json b/package.json index 980f58f..b18933f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.virtuesky.sunflower", "displayName": "Sunflower", "description": "Core ScriptableObject Architecture for building Unity games", - "version": "3.2.4", + "version": "3.2.5", "unity": "2022.3", "category": "virtuesky", "license": "MIT", @@ -16,6 +16,7 @@ "com.unity.serialization": "3.1.1", "com.unity.collections": "2.1.4", "com.unity.textmeshpro": "3.0.8", - "com.unity.addressables": "1.21.21" + "com.unity.addressables": "1.21.21", + "com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask#2.5.10" } } \ No newline at end of file