Singularity/Library/PackageCache/com.unity.2d.animation@7.0.10/Editor/SkinningModule/VisibilityTool/VisibilityToolColumnHeader.cs
2024-05-06 11:45:45 -07:00

36 lines
1.3 KiB
C#

using System;
using UnityEditor.IMGUI.Controls;
using UnityEngine;
namespace UnityEditor.U2D.Animation
{
internal class VisibilityToolColumnHeader : MultiColumnHeader
{
public Action<bool> SetAllVisibility = (b) => {};
public Func<bool> GetAllVisibility = () => true;
public VisibilityToolColumnHeader(MultiColumnHeaderState state)
: base(state)
{
visibilityColumn = -1;
}
public int visibilityColumn { private get; set; }
protected override void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
{
if (columnIndex == visibilityColumn)
{
GUIStyle style = DefaultStyles.columnHeaderCenterAligned;
EditorGUI.BeginChangeCheck();
var visibility = GetAllVisibility();
visibility = GUI.Toggle(headerRect, visibility, visibility ? VisibilityTreeViewBase.VisibilityIconStyle.visibilityOnIcon : VisibilityTreeViewBase.VisibilityIconStyle.visibilityOffIcon, style);
if (EditorGUI.EndChangeCheck())
SetAllVisibility(visibility);
}
else
base.ColumnHeaderGUI(column, headerRect, columnIndex);
}
}
}