Space Ad Mobile 9.5.1
Space Ad Mobile makes ads easy to add into your mobile game: one unified workflow for LevelPlay, AdMob, Yandex.Ads across banners, interstitials and rewarded.
Loading...
Searching...
No Matches
AdUnitBehaviourBase.cs
1using System;
2using UnityEngine;
3
4namespace SCG.SpaceAdMobile
5{
11 [DefaultExecutionOrder(ExecutionOrder)]
12 public abstract class AdUnitBehaviourBase : MonoBehaviour, IAdUnit
13 {
17 public const int ExecutionOrder = -25;
18
19 #region Mono
20
24 protected abstract void Awake();
28 protected abstract void OnEnable();
32 protected abstract void OnDestroy();
36 protected abstract void OnApplicationQuit();
37
41 protected virtual void UnityAwake() { }
45 protected virtual void UnityOnEnable() { }
49 protected virtual void UnityOnDestroy() { }
53 protected virtual void UnityOnApplicationQuit() { }
54 #endregion
55
56 #region IAdUnit
57
59 public abstract AdType AdType { get; }
60
62 public abstract event Action OnShown;
63
64 #endregion
65
66 #region Ad Methods
67
71 public abstract bool Load();
76 public abstract bool CanShowAd();
80 public abstract void Show();
84 public abstract void Unload();
85
89 protected abstract void ShowInternal();
93 protected abstract void DestroyInternal();
94
98 protected virtual void OnUnload() { }
99
100 #endregion
101
102#if UNITY_EDITOR
103 [ContextMenu(nameof(Load))]
104 private void EditorLoad() => Load();
105
106 [ContextMenu(nameof(Show))]
107 private void EditorShow() => Show();
108
109 [ContextMenu(nameof(Unload))]
110 private void EditorUnload() => Unload();
111#endif
112 }
113}
virtual void UnityOnDestroy()
Unity OnDestroy.
const int ExecutionOrder
Executes ad unit components before most other components to avoid Awake and OnEnable races.
virtual void OnUnload()
Called when an ad is unloaded. Can be overridden to perform clean-up or other logic when the ad is no...
virtual void UnityOnApplicationQuit()
Unity OnApplicationQuit.
virtual void UnityOnEnable()
Unity OnEnable.
AdType AdType
Gets the common advertising format exposed by this ad unit.
bool CanShowAd()
Verifies if the ad is ready to be shown.
Base MonoBehaviour class for ad units. This class defines the abstract and virtual properties and met...
void Awake()
Initializes the component during Unity's Awake callback.
void DestroyInternal()
Internal method for unloading an ad. Must be implemented to handle the specific unloading logic.
void ShowInternal()
Internal method for showing an ad. Must be implemented to handle the specific showing logic.
void OnApplicationQuit()
Handles application shutdown.
void OnEnable()
Handles the Unity enable callback.
void OnDestroy()
Releases resources during Unity's destroy callback.
Defines the basic operations required to manage an ad unit lifecycle.
Definition IAdUnit.cs:9