您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
45 行
1.2 KiB
45 行
1.2 KiB
using System.Collections.Generic;
|
|
using UnityEngine.Rendering;
|
|
|
|
namespace UnityEngine.Rendering.UI
|
|
{
|
|
public class DebugUIHandlerPersistentCanvas : MonoBehaviour
|
|
{
|
|
public RectTransform panel;
|
|
public RectTransform valuePrefab;
|
|
|
|
List<DebugUIHandlerValue> m_Items = new List<DebugUIHandlerValue>();
|
|
|
|
internal void Toggle(DebugUI.Value widget)
|
|
{
|
|
int index = m_Items.FindIndex(x => x.GetWidget() == widget);
|
|
|
|
// Remove
|
|
if (index > -1)
|
|
{
|
|
var item = m_Items[index];
|
|
CoreUtils.Destroy(item.gameObject);
|
|
m_Items.RemoveAt(index);
|
|
return;
|
|
}
|
|
|
|
// Add
|
|
var go = Instantiate(valuePrefab, panel, false).gameObject;
|
|
go.name = widget.displayName;
|
|
var uiHandler = go.GetComponent<DebugUIHandlerValue>();
|
|
uiHandler.SetWidget(widget);
|
|
m_Items.Add(uiHandler);
|
|
}
|
|
|
|
internal void Clear()
|
|
{
|
|
if (m_Items == null)
|
|
return;
|
|
|
|
foreach (var item in m_Items)
|
|
CoreUtils.Destroy(item.gameObject);
|
|
|
|
m_Items.Clear();
|
|
}
|
|
}
|
|
}
|