您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
35 行
1.1 KiB
35 行
1.1 KiB
using System;
|
|
using UnityEditor;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace Unity.Services.Core.Editor
|
|
{
|
|
static class OfflineUiHelper
|
|
{
|
|
const string k_UxmlPath = "Packages/com.unity.services.core/Editor/Core/UiHelpers/UXML/Offline.uxml";
|
|
const string k_ButtonClassName = "submit-button";
|
|
|
|
public static void AddOfflineUI(VisualElement offlineContainer, Action buttonClickAction)
|
|
{
|
|
if (offlineContainer == null)
|
|
return;
|
|
|
|
var visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(k_UxmlPath);
|
|
if (visualTreeAsset != null)
|
|
{
|
|
visualTreeAsset.CloneTree(offlineContainer);
|
|
|
|
SetupButton(offlineContainer, buttonClickAction);
|
|
}
|
|
}
|
|
|
|
static void SetupButton(VisualElement buttonContainer, Action buttonClickAction)
|
|
{
|
|
var button = buttonContainer.Q<Button>(className: k_ButtonClassName);
|
|
if (button != null)
|
|
{
|
|
button.clickable.clicked += () => buttonClickAction?.Invoke();
|
|
}
|
|
}
|
|
}
|
|
}
|