Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added warning if no event system for consent form interaction #3102

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

using GoogleMobileAds.Ump.Api;
using GoogleMobileAds.Ump.Common;
Expand Down Expand Up @@ -112,6 +113,7 @@ public void ShowPrivacyOptionsForm(Action<FormError> onDismissed)
/// </summary>
private void AddClickBehavior(GameObject placeholder, Action<FormError> onClick)
{
WarnIfNoEventSystem();
Image[] images = placeholder.GetComponentsInChildren<Image>();
Image adImage = images[1];
Button button = adImage.GetComponentInChildren<Button>();
Expand Down Expand Up @@ -146,5 +148,16 @@ private void DestroyConsentForm()
_formBehaviour.DestroyForm(_placeholderForm);
_prefabForm = null;
}

/// <summary>
/// Logs a warning if no UI event system available in the current scene.
/// </summary>
private void WarnIfNoEventSystem()
{
if (EventSystem.current == null)
{
Debug.LogWarning("No event system available in the current scene. You need to add an UI Event System for interacting with the consent form.");
}
}
}
}