UI 자동화를 위해 바인딩 기능 구현
- 유니티 에셋 인증 오류로 meta 재생성
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#if UNITY_EDITOR
|
||||
using System;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
|
||||
#if UNITY_6000_2_OR_NEWER
|
||||
using TreeView = UnityEditor.IMGUI.Controls.TreeView<int>;
|
||||
using TreeViewItem = UnityEditor.IMGUI.Controls.TreeViewItem<int>;
|
||||
#endif
|
||||
|
||||
namespace UnityEngine.InputSystem.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for working with tree views.
|
||||
/// </summary>
|
||||
/// <seealso cref="TreeView"/>
|
||||
internal static class TreeViewHelpers
|
||||
{
|
||||
public static TItem TryFindItemInHierarchy<TItem>(this TreeViewItem item)
|
||||
where TItem : TreeViewItem
|
||||
{
|
||||
while (item != null)
|
||||
{
|
||||
if (item is TItem result)
|
||||
return result;
|
||||
item = item.parent;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool IsParentOf(this TreeViewItem parent, TreeViewItem child)
|
||||
{
|
||||
if (parent == null)
|
||||
throw new ArgumentNullException(nameof(parent));
|
||||
if (child == null)
|
||||
throw new ArgumentNullException(nameof(child));
|
||||
|
||||
do
|
||||
{
|
||||
child = child.parent;
|
||||
}
|
||||
while (child != null && child != parent);
|
||||
return child != null;
|
||||
}
|
||||
|
||||
public static void ExpandChildren(this TreeView treeView, TreeViewItem item)
|
||||
{
|
||||
if (!item.hasChildren)
|
||||
return;
|
||||
|
||||
foreach (var child in item.children)
|
||||
treeView.SetExpanded(child.id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // UNITY_EDITOR
|
||||
Reference in New Issue
Block a user