using System;
using System.Collections.Generic;
using UnityEngine;
namespace UnityEditor.Rendering.Toon
{
///
/// Collection to store
///
public class UTS3MaterialHeaderScopeList
{
internal readonly uint m_DefaultExpandedState;
internal readonly List m_Items = new List();
///
/// Constructor that initializes it with the default expanded state for the internal scopes
///
/// By default, everything is expanded
public UTS3MaterialHeaderScopeList(uint defaultExpandedState = uint.MaxValue)
{
m_DefaultExpandedState = defaultExpandedState;
}
///
/// Registers a into the list
///
/// The title of the scope
/// The mask identifying the scope
/// The action that will be drawn if the scope is expanded
/// UTS workflow mode ///
/// Flag transparent material header should be drawn ///
/// Flag Tessellation material header should be drawn ///
public void RegisterHeaderScope(GUIContent title, TEnum expandable, Action action, uint isTransparent, uint isTessellation)
where TEnum : struct, IConvertible
{
m_Items.Add(new UTS3MaterialHeaderScopeItem()
{
headerTitle = title,
expandable = Convert.ToUInt32(expandable),
drawMaterialScope = action,
#if UNITY_2021_1_OR_NEWER
url = UTS3DocumentationUtils.GetHelpURL(expandable),
#else
url = string.Empty,
#endif
transparentEnabled = isTransparent,
tessellationEnabled = isTessellation
});
}
///
/// Draws all the with its information stored
///
///
///
public void DrawHeaders(MaterialEditor materialEditor, Material material)
{
if (material == null)
throw new ArgumentNullException(nameof(material));
if (materialEditor == null)
throw new ArgumentNullException(nameof(materialEditor));
foreach (UTS3MaterialHeaderScopeItem item in m_Items)
{
using (UTS3MaterialHeaderScope header = new UTS3MaterialHeaderScope(
item.headerTitle,
item.expandable,
materialEditor,
defaultExpandedState: m_DefaultExpandedState,
documentationURL: item.url))
{
if (!header.expanded)
continue;
EditorGUILayout.Space();
}
}
}
}
}