Class ObservableList<T>
Observable list.
Namespace: UnityEngine.Rendering
Syntax
public class ObservableList<T> : IList<T>
Type Parameters
Name | Description |
---|---|
T | Type of the list. |
Constructors
ObservableList()
Default Constructor.
Declaration
public ObservableList()
ObservableList(IEnumerable<T>)
Constructor.
Declaration
public ObservableList(IEnumerable<T> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | collection | Input list. |
ObservableList(Int32)
Constructor.
Declaration
public ObservableList(int capacity)
Parameters
Type | Name | Description |
---|---|---|
Int32 | capacity | Allocation size. |
Properties
Count
Number of elements in the list.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
Int32 |
IsReadOnly
Is the list read only?
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
Boolean |
Item[Int32]
Accessor.
Declaration
public T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Item index. |
Property Value
Type | Description |
---|---|
T | The item at the provided index. |
Methods
Add(T)
Add an item to the list.
Declaration
public void Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to add to the list. |
Add(T[])
Add multiple objects to the list.
Declaration
public void Add(params T[] items)
Parameters
Type | Name | Description |
---|---|---|
T[] | items | Items to add to the list. |
Clear()
Clear the list.
Declaration
public void Clear()
Contains(T)
Check if an element is present in the list.
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to test against. |
Returns
Type | Description |
---|---|
Boolean | True if the item is in the list. |
CopyTo(T[], Int32)
Copy items in the list to an array.
Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
T[] | array | Destination array. |
Int32 | arrayIndex | Starting index. |
GetEnumerator()
Get enumerator.
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<T> | The list enumerator. |
IndexOf(T)
Get the index of an item.
Declaration
public int IndexOf(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The object to locate in the list. |
Returns
Type | Description |
---|---|
Int32 | The index of the item in the list if it exists, -1 otherwise. |
Insert(Int32, T)
Insert an item in the list.
Declaration
public void Insert(int index, T item)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index at which to insert the new item. |
T | item | Item to insert in the list. |
Remove(T)
Remove an item from the list.
Declaration
public bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to remove from the list. |
Returns
Type | Description |
---|---|
Boolean | True if the item was successfuly removed. False otherise. |
Remove(T[])
Remove multiple items from the list.
Declaration
public int Remove(params T[] items)
Parameters
Type | Name | Description |
---|---|---|
T[] | items | Items to remove from the list. |
Returns
Type | Description |
---|---|
Int32 | The number of removed items. |
RemoveAt(Int32)
Remove an item at a specific index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index of the item to remove. |
Events
ItemAdded
Added item event.
Declaration
public event ListChangedEventHandler<T> ItemAdded
Event Type
Type | Description |
---|---|
ListChangedEventHandler<T> |
ItemRemoved
Removed item event.
Declaration
public event ListChangedEventHandler<T> ItemRemoved
Event Type
Type | Description |
---|---|
ListChangedEventHandler<T> |