Firstborn/Library/PackageCache/com.unity.ads@3.7.5/Editor/DevX/Settings/TestModeUi.cs
Schaken-Mods b486678290 Library -Artifacts
Library -Artifacts
2023-03-28 12:24:16 -05:00

40 lines
1.2 KiB
C#

#if SERVICES_SDK_CORE_ENABLED
using UnityEditor.Advertisements;
using UnityEngine.UIElements;
namespace UnityEngine.Advertisements.Editor
{
class TestModeUi : VisualElement
{
public TestModeUi()
{
var container = UiUtils.GetUiFromTemplate(UiConstants.UiTemplatePaths.TestMode);
if (container is null)
{
var message = string.Format(
UiConstants.Formats.TemplateNotFound, nameof(UiConstants.UiTemplatePaths.TestMode));
Debug.LogError(message);
return;
}
Add(container);
var toggle = container.Q<Toggle>(UiConstants.UiElementNames.TestModeToggle);
if (toggle is null)
{
return;
}
toggle.SetValueWithoutNotify(AdvertisementSettings.testMode);
toggle.RegisterValueChangedCallback(OnTestModeToggleChanged);
}
static void OnTestModeToggleChanged(ChangeEvent<bool> changeEvent)
{
EditorGameServiceAnalyticsSender.SendProjectSettingsEnableTestModeEvent(changeEvent.newValue);
AdvertisementSettings.testMode = changeEvent.newValue;
}
}
}
#endif