diff --git a/Core/Runtime/MonoGlobal.cs b/Core/Runtime/MonoGlobal.cs index 29908da..0aa3ec7 100644 --- a/Core/Runtime/MonoGlobal.cs +++ b/Core/Runtime/MonoGlobal.cs @@ -127,7 +127,7 @@ private void OnApplicationFocus(bool hasFocus) private void OnApplicationPause(bool pauseStatus) { OnGamePause?.Invoke(pauseStatus); - if (pauseStatus) + if (pauseStatus && GameData.IsAutoSave) { GameData.Save(); } @@ -136,7 +136,10 @@ private void OnApplicationPause(bool pauseStatus) private void OnApplicationQuit() { OnGameQuit?.Invoke(); - GameData.Save(); + if (GameData.IsAutoSave) + { + GameData.Save(); + } } #endregion diff --git a/Module/Advertising/Runtime/Admob/AdmobClient.cs b/Module/Advertising/Runtime/Admob/AdmobClient.cs index 1428cd7..f8c04fd 100644 --- a/Module/Advertising/Runtime/Admob/AdmobClient.cs +++ b/Module/Advertising/Runtime/Admob/AdmobClient.cs @@ -1,7 +1,6 @@ #if VIRTUESKY_ADS && VIRTUESKY_ADMOB using GoogleMobileAds.Api; #endif -using System; using VirtueSky.Core; namespace VirtueSky.Ads @@ -43,10 +42,55 @@ public override void Initialize() LoadRewardedInterstitial(); LoadAppOpen(); LoadNativeOverlay(); + LoadBanner(); #endif } - void LoadNativeOverlay() + public override AdUnit InterstitialAdUnit() => AdSettings.AdmobInterstitialAdUnit; + + public override void LoadInterstitial() + { + if (!AdSettings.AdmobInterstitialAdUnit.IsReady()) AdSettings.AdmobInterstitialAdUnit.Load(); + } + + public override AdUnit RewardAdUnit() => AdSettings.AdmobRewardAdUnit; + + public override void LoadRewarded() + { + if (!AdSettings.AdmobRewardAdUnit.IsReady()) AdSettings.AdmobRewardAdUnit.Load(); + } + + public override AdUnit RewardedInterstitialAdUnit() => AdSettings.AdmobRewardedInterstitialAdUnit; + + public override void LoadRewardedInterstitial() + { + if (!AdSettings.AdmobRewardedInterstitialAdUnit.IsReady()) + AdSettings.AdmobRewardedInterstitialAdUnit.Load(); + } + + public override AdUnit AppOpenAdUnit() => AdSettings.AdmobAppOpenAdUnit; + + public override void LoadAppOpen() + { + if (!AdSettings.AdmobAppOpenAdUnit.IsReady()) AdSettings.AdmobAppOpenAdUnit.Load(); + } + + public override void ShowAppOpen() + { + if (statusAppOpenFirstIgnore) AdSettings.AdmobAppOpenAdUnit.Show(); + statusAppOpenFirstIgnore = true; + } + + public override AdUnit BannerAdUnit() => AdSettings.AdmobBannerAdUnit; + + public override void LoadBanner() + { + AdSettings.AdmobBannerAdUnit.Load(); + } + + public override AdUnit NativeOverlayAdUnit() => AdSettings.AdmobNativeOverlayAdUnit; + + public override void LoadNativeOverlay() { if (!AdSettings.AdmobNativeOverlayAdUnit.IsReady()) { diff --git a/Module/Advertising/Runtime/General/AdClient.cs b/Module/Advertising/Runtime/General/AdClient.cs index 8aea6d3..b2166d8 100644 --- a/Module/Advertising/Runtime/General/AdClient.cs +++ b/Module/Advertising/Runtime/General/AdClient.cs @@ -2,150 +2,25 @@ namespace VirtueSky.Ads { public abstract class AdClient { - private bool statusAppOpenFirstIgnore; + protected bool statusAppOpenFirstIgnore; public abstract void Initialize(); - - #region Inter Ad - - public AdUnit InterstitialAdUnit() - { - return AdSettings.CurrentAdNetwork switch - { - AdNetwork.Max => AdSettings.MaxInterstitialAdUnit, - AdNetwork.Admob => AdSettings.AdmobInterstitialAdUnit, - _ => AdSettings.IronSourceInterstitialAdUnit, - }; - } - - protected virtual bool IsInterstitialReady() - { - return InterstitialAdUnit().IsReady(); - } - - public virtual void LoadInterstitial() - { - if (InterstitialAdUnit() == null) return; - if (!IsInterstitialReady()) InterstitialAdUnit().Load(); - } - - #endregion - - #region Reward Ad - - public AdUnit RewardAdUnit() - { - return AdSettings.CurrentAdNetwork switch - { - AdNetwork.Max => AdSettings.MaxRewardAdUnit, - AdNetwork.Admob => AdSettings.AdmobRewardAdUnit, - _ => AdSettings.IronSourceRewardAdUnit, - }; - } - - protected virtual bool IsRewardedReady() - { - return RewardAdUnit().IsReady(); - } - - public virtual void LoadRewarded() - { - if (RewardAdUnit() == null) return; - if (!IsRewardedReady()) RewardAdUnit().Load(); - } - - #endregion - - #region Reward Inter Ad - - public AdUnit RewardedInterstitialAdUnit() - { - return AdSettings.CurrentAdNetwork switch - { - AdNetwork.Max => AdSettings.MaxRewardedInterstitialAdUnit, - AdNetwork.Admob => AdSettings.AdmobRewardedInterstitialAdUnit, - _ => null - }; - } - - protected virtual bool IsRewardedInterstitialReady() - { - return RewardedInterstitialAdUnit().IsReady(); - } - - public virtual void LoadRewardedInterstitial() - { - if (RewardedInterstitialAdUnit() == null) return; - if (!IsRewardedInterstitialReady()) RewardedInterstitialAdUnit().Load(); - } - - #endregion - - #region AppOpen Ad - - public AdUnit AppOpenAdUnit() - { - return AdSettings.CurrentAdNetwork switch - { - AdNetwork.Max => AdSettings.MaxAppOpenAdUnit, - AdNetwork.Admob => AdSettings.AdmobAppOpenAdUnit, - _ => 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 - - #region Banner Ad - - public AdUnit BannerAdUnit() - { - return AdSettings.CurrentAdNetwork switch - { - AdNetwork.Max => AdSettings.MaxBannerAdUnit, - AdNetwork.Admob => AdSettings.AdmobBannerAdUnit, - _ => AdSettings.IronSourceBannerAdUnit - }; - } - - #endregion - - #region Native Overlay Ad + public abstract AdUnit InterstitialAdUnit(); + public abstract void LoadInterstitial(); + public abstract AdUnit RewardAdUnit(); + public abstract void LoadRewarded(); + public abstract AdUnit RewardedInterstitialAdUnit(); + public abstract void LoadRewardedInterstitial(); + public abstract AdUnit AppOpenAdUnit(); + public abstract void LoadAppOpen(); + public abstract void ShowAppOpen(); + public abstract AdUnit BannerAdUnit(); + + public abstract void LoadBanner(); // Native overlay only for admob - public AdUnit NativeOverlayAdUnit() - { - return AdSettings.AdmobNativeOverlayAdUnit; - } - - protected virtual bool IsNativeOverlayAdReady() - { - return NativeOverlayAdUnit().IsReady(); - } - - public virtual void LoadNativeOverlayAd() - { - if (NativeOverlayAdUnit() == null) return; - if (!IsNativeOverlayAdReady()) NativeOverlayAdUnit().Load(); - } - - #endregion + public abstract AdUnit NativeOverlayAdUnit(); + public abstract void LoadNativeOverlay(); } } \ No newline at end of file diff --git a/Module/Advertising/Runtime/IronSource/IronSourceClient.cs b/Module/Advertising/Runtime/IronSource/IronSourceClient.cs index 24ce838..d3236f9 100644 --- a/Module/Advertising/Runtime/IronSource/IronSourceClient.cs +++ b/Module/Advertising/Runtime/IronSource/IronSourceClient.cs @@ -28,6 +28,59 @@ public override void Initialize() #endif LoadInterstitial(); LoadRewarded(); + LoadBanner(); + } + + public override AdUnit InterstitialAdUnit() => AdSettings.IronSourceInterstitialAdUnit; + + public override void LoadInterstitial() + { + if (!AdSettings.IronSourceInterstitialAdUnit.IsReady()) AdSettings.IronSourceInterstitialAdUnit.Load(); + } + + public override AdUnit RewardAdUnit() => AdSettings.IronSourceRewardAdUnit; + + public override void LoadRewarded() + { + if (!AdSettings.IronSourceRewardAdUnit.IsReady()) AdSettings.IronSourceRewardAdUnit.Load(); + } + + public override AdUnit RewardedInterstitialAdUnit() + { + return null; + } + + public override void LoadRewardedInterstitial() + { + } + + public override AdUnit AppOpenAdUnit() + { + return null; + } + + public override void LoadAppOpen() + { + } + + public override void ShowAppOpen() + { + } + + public override AdUnit BannerAdUnit() => AdSettings.IronSourceBannerAdUnit; + + public override void LoadBanner() + { + AdSettings.IronSourceBannerAdUnit.Load(); + } + + public override AdUnit NativeOverlayAdUnit() + { + return null; + } + + public override void LoadNativeOverlay() + { } #if VIRTUESKY_ADS && VIRTUESKY_IRONSOURCE private void ImpressionDataReadyEvent(IronSourceImpressionData impressionData) diff --git a/Module/Advertising/Runtime/Max/MaxAdClient.cs b/Module/Advertising/Runtime/Max/MaxAdClient.cs index 4596eb3..ff7d4d8 100644 --- a/Module/Advertising/Runtime/Max/MaxAdClient.cs +++ b/Module/Advertising/Runtime/Max/MaxAdClient.cs @@ -19,8 +19,60 @@ public override void Initialize() LoadRewarded(); LoadRewardedInterstitial(); LoadAppOpen(); + LoadBanner(); #endif } + + public override AdUnit InterstitialAdUnit() => AdSettings.MaxInterstitialAdUnit; + + public override void LoadInterstitial() + { + if (!AdSettings.MaxInterstitialAdUnit.IsReady()) AdSettings.MaxInterstitialAdUnit.Load(); + } + + public override AdUnit RewardAdUnit() => AdSettings.MaxRewardAdUnit; + + public override void LoadRewarded() + { + if (!AdSettings.MaxRewardAdUnit.IsReady()) AdSettings.MaxRewardAdUnit.Load(); + } + + public override AdUnit RewardedInterstitialAdUnit() => AdSettings.MaxRewardedInterstitialAdUnit; + + public override void LoadRewardedInterstitial() + { + if (!AdSettings.MaxRewardedInterstitialAdUnit.IsReady()) AdSettings.MaxRewardedInterstitialAdUnit.Load(); + } + + public override AdUnit AppOpenAdUnit() => AdSettings.MaxAppOpenAdUnit; + + public override void LoadAppOpen() + { + if (!AdSettings.MaxAppOpenAdUnit.IsReady()) AdSettings.MaxAppOpenAdUnit.Load(); + } + + public override void ShowAppOpen() + { + if (statusAppOpenFirstIgnore) AdSettings.MaxAppOpenAdUnit.Show(); + statusAppOpenFirstIgnore = true; + } + + public override AdUnit BannerAdUnit() => AdSettings.MaxBannerAdUnit; + + public override void LoadBanner() + { + AdSettings.MaxBannerAdUnit.Load(); + } + + public override AdUnit NativeOverlayAdUnit() + { + return null; + } + + public override void LoadNativeOverlay() + { + } + #if VIRTUESKY_ADS && VIRTUESKY_APPLOVIN private void OnAppStateChange(bool pauseStatus) { diff --git a/Module/ControlPanel/ConstantPackage.cs b/Module/ControlPanel/ConstantPackage.cs index 39d9daa..beac69a 100644 --- a/Module/ControlPanel/ConstantPackage.cs +++ b/Module/ControlPanel/ConstantPackage.cs @@ -2,7 +2,7 @@ { public class ConstantPackage { - public const string VersionUnityCommon = "1.4.8"; + public const string VersionUnityCommon = "1.4.9"; public const string PackageNameInAppPurchase = "com.unity.purchasing"; public const string MaxVersionInAppPurchase = "4.12.2"; public const string PackageNameNewtonsoftJson = "com.unity.nuget.newtonsoft-json"; @@ -30,7 +30,8 @@ public class ConstantPackage public const string PackageNameGGExternalDependencyManager = "com.google.external-dependency-manager"; - public const string MaxVersionGGExternalDependencyManager = "https://github.com/googlesamples/unity-jar-resolver.git?path=upm#v1.2.183"; + public const string MaxVersionGGExternalDependencyManager = + "https://github.com/googlesamples/unity-jar-resolver.git?path=upm#v1.2.183"; public const string PackageNameGGPlayReview = "com.google.play.review"; @@ -96,12 +97,12 @@ 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"; diff --git a/Module/DataStorage/Runtime/GameData.cs b/Module/DataStorage/Runtime/GameData.cs index 959e1ba..d917ce9 100644 --- a/Module/DataStorage/Runtime/GameData.cs +++ b/Module/DataStorage/Runtime/GameData.cs @@ -12,7 +12,7 @@ public static class GameData private static int profile; private static Dictionary datas = new(); private const int INIT_SIZE = 64; - + public static bool IsAutoSave { get; set; } = true; public static event Action OnSaveEvent; #region Internal Stuff diff --git a/README.md b/README.md index c5ed528..174d924 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 `1.4.8` +for version `1.4.9` ```csharp -"com.wolf-org.sunflower2":"https://github.com/unity-package/sunflower_2.git#1.4.8", +"com.wolf-org.sunflower2":"https://github.com/unity-package/sunflower_2.git#1.4.9", ``` ## Includes modules diff --git a/package.json b/package.json index beeb950..a1949e6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.wolf-org.sunflower2", "displayName": "Sunflower2", "description": "Core singleton for building Unity games ", - "version": "1.4.8", + "version": "1.4.9", "unity": "2022.3", "category": "virtuesky", "license": "MIT", @@ -20,6 +20,7 @@ "com.unity.serialization": "3.1.1", "com.unity.collections": "2.1.4", "com.unity.textmeshpro": "3.0.8", - "com.unity.addressables": "1.21.20" + "com.unity.addressables": "1.21.20", + "com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask#2.5.10" } } \ No newline at end of file