Skip to content

Commit

Permalink
Merge pull request #22 from wolf-org/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
VirtueSky authored Oct 23, 2024
2 parents 1eec2e3 + a26ed8a commit a58d84d
Show file tree
Hide file tree
Showing 27 changed files with 384 additions and 308 deletions.
34 changes: 0 additions & 34 deletions Core/Runtime/Singleton.cs

This file was deleted.

3 changes: 0 additions & 3 deletions Core/Runtime/Singleton.cs.meta

This file was deleted.

18 changes: 9 additions & 9 deletions Module/Advertising/Runtime/Admob/AdmobClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ public override void Initialize()
{
App.RunOnMainThread(() =>
{
if (!adSettings.AdmobEnableTestMode) return;
if (!AdSettings.AdmobEnableTestMode) return;
var configuration = new RequestConfiguration
{ TestDeviceIds = adSettings.AdmobDevicesTest };
{ TestDeviceIds = AdSettings.AdmobDevicesTest };
MobileAds.SetRequestConfiguration(configuration);
});
});
adSettings.AdmobBannerAdUnit.Init();
adSettings.AdmobInterstitialAdUnit.Init();
adSettings.AdmobRewardAdUnit.Init();
adSettings.AdmobRewardedInterstitialAdUnit.Init();
adSettings.AdmobAppOpenAdUnit.Init();
AdSettings.AdmobBannerAdUnit.Init();
AdSettings.AdmobInterstitialAdUnit.Init();
AdSettings.AdmobRewardAdUnit.Init();
AdSettings.AdmobRewardedInterstitialAdUnit.Init();
AdSettings.AdmobAppOpenAdUnit.Init();
RegisterAppStateChange();
LoadInterstitial();
LoadRewarded();
Expand All @@ -53,10 +53,10 @@ public void RegisterAppStateChange()

void OnAppStateChanged(GoogleMobileAds.Common.AppState state)
{
if (state == GoogleMobileAds.Common.AppState.Foreground && adSettings.AdmobAppOpenAdUnit.autoShow &&
if (state == GoogleMobileAds.Common.AppState.Foreground && AdSettings.AdmobAppOpenAdUnit.autoShow &&
!AdStatic.isShowingAd)
{
if (adSettings.CurrentAdNetwork == AdNetwork.Admob) ShowAppOpen();
if (AdSettings.CurrentAdNetwork == AdNetwork.Admob) ShowAppOpen();
}
}
#endif
Expand Down
43 changes: 18 additions & 25 deletions Module/Advertising/Runtime/General/AdClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ namespace VirtueSky.Ads
{
public abstract class AdClient
{
protected AdSettings adSettings;

public void SetupAdSettings(AdSettings _adSettings)
{
this.adSettings = _adSettings;
}

private bool statusAppOpenFirstIgnore;


Expand All @@ -18,11 +11,11 @@ public void SetupAdSettings(AdSettings _adSettings)

public AdUnit InterstitialAdUnit()
{
return adSettings.CurrentAdNetwork switch
return AdSettings.CurrentAdNetwork switch
{
AdNetwork.Max => adSettings.MaxInterstitialAdUnit,
AdNetwork.Admob => adSettings.AdmobInterstitialAdUnit,
_ => adSettings.IronSourceInterstitialAdUnit,
AdNetwork.Max => AdSettings.MaxInterstitialAdUnit,
AdNetwork.Admob => AdSettings.AdmobInterstitialAdUnit,
_ => AdSettings.IronSourceInterstitialAdUnit,
};
}

Expand All @@ -43,11 +36,11 @@ public virtual void LoadInterstitial()

public AdUnit RewardAdUnit()
{
return adSettings.CurrentAdNetwork switch
return AdSettings.CurrentAdNetwork switch
{
AdNetwork.Max => adSettings.MaxRewardAdUnit,
AdNetwork.Admob => adSettings.AdmobRewardAdUnit,
_ => adSettings.IronSourceRewardAdUnit,
AdNetwork.Max => AdSettings.MaxRewardAdUnit,
AdNetwork.Admob => AdSettings.AdmobRewardAdUnit,
_ => AdSettings.IronSourceRewardAdUnit,
};
}

Expand All @@ -68,10 +61,10 @@ public virtual void LoadRewarded()

public AdUnit RewardedInterstitialAdUnit()
{
return adSettings.CurrentAdNetwork switch
return AdSettings.CurrentAdNetwork switch
{
AdNetwork.Max => adSettings.MaxRewardedInterstitialAdUnit,
AdNetwork.Admob => adSettings.AdmobRewardedInterstitialAdUnit,
AdNetwork.Max => AdSettings.MaxRewardedInterstitialAdUnit,
AdNetwork.Admob => AdSettings.AdmobRewardedInterstitialAdUnit,
_ => null
};
}
Expand All @@ -93,10 +86,10 @@ public virtual void LoadRewardedInterstitial()

public AdUnit AppOpenAdUnit()
{
return adSettings.CurrentAdNetwork switch
return AdSettings.CurrentAdNetwork switch
{
AdNetwork.Max => adSettings.MaxAppOpenAdUnit,
AdNetwork.Admob => adSettings.AdmobAppOpenAdUnit,
AdNetwork.Max => AdSettings.MaxAppOpenAdUnit,
AdNetwork.Admob => AdSettings.AdmobAppOpenAdUnit,
_ => null
};
}
Expand Down Expand Up @@ -124,11 +117,11 @@ public virtual void ShowAppOpen()

public AdUnit BannerAdUnit()
{
return adSettings.CurrentAdNetwork switch
return AdSettings.CurrentAdNetwork switch
{
AdNetwork.Max => adSettings.MaxBannerAdUnit,
AdNetwork.Admob => adSettings.AdmobBannerAdUnit,
_ => adSettings.IronSourceBannerAdUnit
AdNetwork.Max => AdSettings.MaxBannerAdUnit,
AdNetwork.Admob => AdSettings.AdmobBannerAdUnit,
_ => AdSettings.IronSourceBannerAdUnit
};
}

Expand Down
74 changes: 37 additions & 37 deletions Module/Advertising/Runtime/General/AdSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public class AdSettings : ScriptableSettings<AdSettings>
[SerializeField] private MaxRewardedInterstitialAdUnit maxRewardedInterstitialAdUnit;
[SerializeField] private MaxAppOpenAdUnit maxAppOpenAdUnit;

public string SdkKey => Instance.sdkKey;
public static string SdkKey => Instance.sdkKey;

public MaxBannerAdUnit MaxBannerAdUnit => Instance.maxBannerAdUnit;
public MaxInterstitialAdUnit MaxInterstitialAdUnit => Instance.maxInterstitialAdUnit;
public MaxRewardAdUnit MaxRewardAdUnit => Instance.maxRewardAdUnit;
public static MaxBannerAdUnit MaxBannerAdUnit => Instance.maxBannerAdUnit;
public static MaxInterstitialAdUnit MaxInterstitialAdUnit => Instance.maxInterstitialAdUnit;
public static MaxRewardAdUnit MaxRewardAdUnit => Instance.maxRewardAdUnit;

public MaxRewardedInterstitialAdUnit MaxRewardedInterstitialAdUnit =>
public static MaxRewardedInterstitialAdUnit MaxRewardedInterstitialAdUnit =>
Instance.maxRewardedInterstitialAdUnit;

public MaxAppOpenAdUnit MaxAppOpenAdUnit => Instance.maxAppOpenAdUnit;
public static MaxAppOpenAdUnit MaxAppOpenAdUnit => Instance.maxAppOpenAdUnit;

#endregion

Expand All @@ -54,13 +54,13 @@ public class AdSettings : ScriptableSettings<AdSettings>
[SerializeField] private List<string> admobDevicesTest;


public AdmobBannerAdUnit AdmobBannerAdUnit => admobBannerAdUnit;
public AdmobInterstitialAdUnit AdmobInterstitialAdUnit => admobInterstitialAdUnit;
public AdmobRewardAdUnit AdmobRewardAdUnit => admobRewardAdUnit;
public AdmobRewardedInterstitialAdUnit AdmobRewardedInterstitialAdUnit => admobRewardedInterstitialAdUnit;
public AdmobAppOpenAdUnit AdmobAppOpenAdUnit => admobAppOpenAdUnit;
public bool AdmobEnableTestMode => admobEnableTestMode;
public List<string> AdmobDevicesTest => admobDevicesTest;
public static AdmobBannerAdUnit AdmobBannerAdUnit => Instance.admobBannerAdUnit;
public static AdmobInterstitialAdUnit AdmobInterstitialAdUnit => Instance.admobInterstitialAdUnit;
public static AdmobRewardAdUnit AdmobRewardAdUnit => Instance.admobRewardAdUnit;
public static AdmobRewardedInterstitialAdUnit AdmobRewardedInterstitialAdUnit => Instance.admobRewardedInterstitialAdUnit;
public static AdmobAppOpenAdUnit AdmobAppOpenAdUnit => Instance.admobAppOpenAdUnit;
public static bool AdmobEnableTestMode => Instance.admobEnableTestMode;
public static List<string> AdmobDevicesTest => Instance.admobDevicesTest;

#endregion

Expand All @@ -73,60 +73,60 @@ public class AdSettings : ScriptableSettings<AdSettings>
[SerializeField] private IronSourceInterstitialAdUnit ironSourceInterstitialAdUnit;
[SerializeField] private IronSourceRewardAdUnit ironSourceRewardAdUnit;

public string AndroidAppKey
public static string AndroidAppKey
{
get => androidAppKey;
set => androidAppKey = value;
get => Instance.androidAppKey;
set => Instance.androidAppKey = value;
}

public string IosAppKey
public static string IosAppKey
{
get => iOSAppKey;
set => iOSAppKey = value;
get => Instance.iOSAppKey;
set => Instance.iOSAppKey = value;
}

public string AppKey
public static string AppKey
{
get
{
#if UNITY_ANDROID
return androidAppKey;
return Instance.androidAppKey;
#elif UNITY_IOS
return iOSAppKey;
return Instance.iOSAppKey;
#else
return string.Empty;
#endif
}
set
{
#if UNITY_ANDROID
androidAppKey = value;
Instance.androidAppKey = value;
#elif UNITY_IOS
iOSAppKey = value;
Instance.iOSAppKey = value;
#endif
}
}

public bool UseTestAppKey => useTestAppKey;
public IronSourceBannerAdUnit IronSourceBannerAdUnit => ironSourceBannerAdUnit;
public IronSourceInterstitialAdUnit IronSourceInterstitialAdUnit => ironSourceInterstitialAdUnit;
public IronSourceRewardAdUnit IronSourceRewardAdUnit => ironSourceRewardAdUnit;
public static bool UseTestAppKey => Instance.useTestAppKey;
public static IronSourceBannerAdUnit IronSourceBannerAdUnit => Instance.ironSourceBannerAdUnit;
public static IronSourceInterstitialAdUnit IronSourceInterstitialAdUnit => Instance.ironSourceInterstitialAdUnit;
public static IronSourceRewardAdUnit IronSourceRewardAdUnit => Instance.ironSourceRewardAdUnit;

#endregion

public bool RuntimeAutoInit => runtimeAutoInit;
public CoreEnum.RuntimeAutoInitType RuntimeAutoInitType => runtimeAutoInitType;
public float AdCheckingInterval => adCheckingInterval;
public float AdLoadingInterval => adLoadingInterval;
public static bool RuntimeAutoInit => Instance.runtimeAutoInit;
public static CoreEnum.RuntimeAutoInitType RuntimeAutoInitType => Instance.runtimeAutoInitType;
public static float AdCheckingInterval => Instance.adCheckingInterval;
public static float AdLoadingInterval => Instance.adLoadingInterval;

public AdNetwork CurrentAdNetwork
public static AdNetwork CurrentAdNetwork
{
get => adNetwork;
set => adNetwork = value;
get => Instance.adNetwork;
set => Instance.adNetwork = value;
}

public bool EnableGDPR => enableGDPR;
public bool EnableGDPRTestMode => enableGDPRTestMode;
public static bool EnableGDPR => Instance.enableGDPR;
public static bool EnableGDPRTestMode => Instance.enableGDPRTestMode;
}

public enum AdNetwork
Expand Down
4 changes: 2 additions & 2 deletions Module/Advertising/Runtime/General/AdStatic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ private static void RuntimeAfterSceneLoad()
private static void AutoInitialize(CoreEnum.RuntimeAutoInitType adsRuntimeAutoInitType)
{
if (AdSettings.Instance == null) return;
if (!AdSettings.Instance.RuntimeAutoInit) return;
if (AdSettings.Instance.RuntimeAutoInitType != adsRuntimeAutoInitType) return;
if (!AdSettings.RuntimeAutoInit) return;
if (AdSettings.RuntimeAutoInitType != adsRuntimeAutoInitType) return;
var ads = new GameObject("Advertising");
ads.AddComponent<Advertising>();
UnityEngine.Object.DontDestroyOnLoad(ads);
Expand Down
Loading

0 comments on commit a58d84d

Please sign in to comment.