mathe/Library/PackageCache/com.unity.shadergraph@14.0.8/Editor/Generation/Collections/PassCollection.cs

67 lines
1.7 KiB
C#
Raw Normal View History

2024-09-20 20:30:10 +02:00
using System.Collections;
using System.Collections.Generic;
namespace UnityEditor.ShaderGraph
{
[GenerationAPI]
internal class PassCollection : IEnumerable<PassCollection.Item>
{
public class Item : IConditional
{
public PassDescriptor descriptor { get; }
public FieldCondition[] fieldConditions { get; }
public Item(PassDescriptor descriptor, FieldCondition[] fieldConditions)
{
this.descriptor = descriptor;
this.fieldConditions = fieldConditions;
}
}
readonly List<Item> m_Items;
public PassCollection()
{
m_Items = new List<Item>();
}
public PassCollection Add(PassCollection passes)
{
foreach (PassCollection.Item item in passes)
{
m_Items.Add(item);
}
return this;
}
public PassCollection Add(PassDescriptor descriptor)
{
m_Items.Add(new Item(descriptor, null));
return this;
}
public PassCollection Add(PassDescriptor descriptor, FieldCondition fieldCondition)
{
m_Items.Add(new Item(descriptor, new FieldCondition[] { fieldCondition }));
return this;
}
public PassCollection Add(PassDescriptor descriptor, FieldCondition[] fieldConditions)
{
m_Items.Add(new Item(descriptor, fieldConditions));
return this;
}
public IEnumerator<Item> GetEnumerator()
{
return m_Items.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}