using ShiroginSDK.Runtime.Modules.Events; using ShiroginSDK.Runtime.Services.Base; using ShiroginSDK.Runtime.Services.Interfaces; using UnityEngine; using UnityEngine.UI; namespace ShiroginSDK.Samples.EventSample.Scripts { /// /// Simple demonstration UI for sending and receiving custom Shirogin events. /// public class EventSampleUI : MonoBehaviour { [SerializeField] private Button noConnectionButton; [SerializeField] private Button rewardedAdUnavailableButton; private IEventService _eventService; private void Awake() { _eventService = ServiceLocator.Get(); } private void OnEnable() { noConnectionButton.onClick?.AddListener(OnNoConnectionButtonClicked); rewardedAdUnavailableButton.onClick?.AddListener(RewardedAdUnavailableButtonClicked); _eventService?.Subscribe(OnNoConnectionEventReceived); _eventService?.Subscribe(OnRewardedAdUnavailable); } private void OnDisable() { if (noConnectionButton != null) noConnectionButton.onClick.RemoveAllListeners(); _eventService?.Unsubscribe(OnNoConnectionEventReceived); _eventService?.Unsubscribe(OnRewardedAdUnavailable); } private void OnNoConnectionEventReceived(ShiroginEvents.Connection.NoConnectionEvent e) { Debug.Log("[EventSampleUI] ❗ No internet connection event received."); } private void OnRewardedAdUnavailable(ShiroginEvents.Ads.RewardedAdUnavailableEvent obj) { Debug.Log("[EventSampleUI] �� Rewarded ad unavailable event received."); } private void OnNoConnectionButtonClicked() { Debug.Log("[EventSampleUI] 🔘 Button clicked — sending NoConnectionEvent."); _eventService?.Invoke(new ShiroginEvents.Connection.NoConnectionEvent()); } private void RewardedAdUnavailableButtonClicked() { Debug.Log("[EventSampleUI] 🔘 Button clicked — sending NoConnectionEvent."); _eventService?.Invoke(new ShiroginEvents.Ads.RewardedAdUnavailableEvent( "Your custom message here! Ad not available at the moment. Please try again later.")); } } }