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

Update GoogleUmpController.cs #2829

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
29 changes: 6 additions & 23 deletions samples/HelloWorld/Assets/Scripts/GoogleUmpController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class GoogleUmpController : MonoBehaviour
private readonly List<string> TEST_DEVICE_IDS = new List<string>
{
AdRequest.TestDeviceSimulator,
"emulator",
"D3008DE61F37216C4657717D479A6463",
// Add your test device IDs (replace with your own device IDs).
#if UNITY_IPHONE
"96e23e80653bb28980d3f40beb58915c",
Expand Down Expand Up @@ -53,9 +55,6 @@ private void Awake()
// This behavior should be made consistent with iOS.
MobileAds.SetiOSAppPauseOnBackground(true);

// This method will configure the UI events.
InitUI();

// This method will redraw the UI.
// Call it whenever there is a change.
UpdateUI();
Expand All @@ -72,8 +71,8 @@ private void Awake()
public void ResetConsentInformation()
{
ConsentInformation.Reset();
UpdateUI();
Debug.Log("Consent information has been reset.");
UpdateUI();
}

/// <summary>
Expand Down Expand Up @@ -101,8 +100,6 @@ public void UpdateConsentInformation()
// OnConsentInformationUpdate
(FormError error) =>
{
UpdateUI();

if (error == null)
{
// The consent information updated successfully.
Expand All @@ -116,7 +113,7 @@ public void UpdateConsentInformation()
Debug.LogError("Failed to update consent information with error: " +
error.Message);
}

UpdateUI();
});
}

Expand All @@ -135,7 +132,6 @@ public void LoadConsentForm()
// OnConsentFormLoad
(ConsentForm form, FormError error) =>
{
UpdateUI();
if (form != null)
{
// The consent form was loaded.
Expand All @@ -149,6 +145,7 @@ public void LoadConsentForm()
Debug.LogError("Failed to load consent form with error: " +
error == null ? "unknown error" : error.Message);
}
UpdateUI();
});
}

Expand All @@ -163,38 +160,24 @@ public void ShowConsentForm()
{
if (error == null)
{
// If the error parameter is null,
// we showed the consent form without error.
UpdateUI();

// Load another consent form for use later.
LoadConsentForm();
}
else
{
// The consent form failed to show.
UpdateUI();
Debug.LogError("Failed to show consent form with error: " +
error.Message);
}
UpdateUI();
});
}

#endregion

#region Utility methods

/// <summary>
/// This method will initialize the UI elements.
/// </summary>
private void InitUI()
{
BtnResetConsentInformation.onClick.AddListener(ResetConsentInformation);
BtnUpdateConsentInformation.onClick.AddListener(UpdateConsentInformation);
BtnLoadConsentForm.onClick.AddListener(LoadConsentForm);
BtnShowConsentForm.onClick.AddListener(ShowConsentForm);
}

/// <summary>
/// This method will update the UI elements with the newly loaded application state.
/// </summary>
Expand Down