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

50 lines
1.4 KiB
C#

#if SERVICES_SDK_CORE_ENABLED
using UnityEditor.Advertisements;
using UnityEngine.UIElements;
namespace UnityEngine.Advertisements.Editor
{
class GameIdsUi : VisualElement
{
VisualElement m_Container;
public GameIdsUi()
{
m_Container = UiUtils.GetUiFromTemplate(UiConstants.UiTemplatePaths.GameIds);
if (m_Container is null)
{
var message = string.Format(
UiConstants.Formats.TemplateNotFound, nameof(UiConstants.UiTemplatePaths.GameIds));
Debug.LogError(message);
return;
}
Add(m_Container);
RefreshGameIds();
}
public void RefreshGameIds()
{
SetUpGameIdFor(RuntimePlatform.IPhonePlayer, UiConstants.UiElementNames.AppleGameId);
SetUpGameIdFor(RuntimePlatform.Android, UiConstants.UiElementNames.AndroidGameId);
MarkDirtyRepaint();
}
void SetUpGameIdFor(RuntimePlatform platform, string fieldName)
{
var gameIdField = m_Container.Q<TextField>(fieldName);
if (gameIdField is null)
{
return;
}
var gameId = AdvertisementSettings.GetGameId(platform)
?? UiConstants.LocalizedStrings.Unavailable;
gameIdField.SetValueWithoutNotify(gameId);
}
}
}
#endif