Class SCP_PaletteProvider
One of the core components of the system, acting as broker between palettes and colorers. Every colorer gets linked to a SCP_PaletteProvider, that handles a list of one or more SCP_Palette instances. Colorers monitor their provider for changes, and the provider themselves monitor their palettes. So, when a palette color changes, the change gets propagated to all the providers holding that palette, and then to all colorers linked to those providers.
For convenience, providers have an "active" palette that is the one that colorers use by default. Changing active palette also refreshes all the linked colorers.
Namespace: BinaryCharm.SemanticColorPalette
Assembly: cs.temp.dll.dll
Syntax
public class SCP_PaletteProvider : MonoBehaviour
Fields
m_stateTracker
State tracking struct. Potentially needs to be accessed in custom providers inheriting from this class.
Declaration
protected MutableStateTracker m_stateTracker
Field Value
| Type | Description |
|---|---|
| MutableStateTracker |
Methods
AddPalette(SCP_Palette)
Adds a palette to the set of palettes managed by the provider. If such set is not empty (that is, the PaletteProvider already handles one or more palettes), the new palette must be compatible with the previously added others, or an Exception is thrown and the palette doesn't get added.
Two palettes A and B are compatible when
- A is a main palette and B is a variant of A
- A and B are both variants of the same main palette
Declaration
public void AddPalette(SCP_Palette rPalette)
Parameters
| Type | Name | Description |
|---|---|---|
| SCP_Palette | rPalette | The Palette to be added. |
GetActivePaletteIndex()
Fetches the active palette index.
Declaration
public int GetActivePaletteIndex()
Returns
| Type | Description |
|---|---|
| Int32 | The active palette index. |
GetNumPalettes()
Fetches the number of palettes currently handled by the provider.
Declaration
public int GetNumPalettes()
Returns
| Type | Description |
|---|---|
| Int32 | The number of palettes currently handled. |
GetPalette()
Fetches the currently active palette.
Declaration
public virtual SCP_Palette GetPalette()
Returns
| Type | Description |
|---|---|
| SCP_Palette | The currently active palette. |
GetPaletteByIndex(Int32)
Fetches the palette specified by iPaletteIndex
Declaration
public SCP_Palette GetPaletteByIndex(int iPaletteIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | iPaletteIndex | The zero-based index of the palette to fetch. |
Returns
| Type | Description |
|---|---|
| SCP_Palette | The requested palette, or null if an out of bounds
|
GetPaletteIndex(SCP_Palette)
Retrieves the current position of rPalette in
the list of palettes handled by the provider. Note that it's an
index and not an identifier, and it might change when removing
other palettes.
Declaration
public int GetPaletteIndex(SCP_Palette rPalette)
Parameters
| Type | Name | Description |
|---|---|---|
| SCP_Palette | rPalette | The palette to look for. |
Returns
| Type | Description |
|---|---|
| Int32 | The index of |
GetStateTracker()
Returns a reference to the state tracking struct.
Declaration
public ref MutableStateTracker GetStateTracker()
Returns
| Type | Description |
|---|---|
| MutableStateTracker | A reference to the state tracking struct. |
Remarks
Should never be used in everyday application code.
OnDestroy()
Declaration
protected void OnDestroy()
OnDisable()
Declaration
protected void OnDisable()
OnEnable()
Declaration
protected void OnEnable()
OnValidate()
Declaration
protected void OnValidate()
RemPalette(SCP_Palette)
Removes rPalette from the list of handled
palettes. If rPalette is not in such list,
it throws an exception.
Declaration
public void RemPalette(SCP_Palette rPalette)
Parameters
| Type | Name | Description |
|---|---|---|
| SCP_Palette | rPalette | Reference to the palette to remove. |
Remarks
Removing a palette from the list might invalidate the configuration of any colorers referring to this palette provider.
RemPaletteByIndex(Int32)
Removes the palette at index iPaletteIndex from
the set of handled palettes. If iPaletteIndex is
not valid (that is: not between 0 and
GetNumPalettes() - 1),
throws an exception.
Declaration
public void RemPaletteByIndex(int iPaletteIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | iPaletteIndex | Index of the palette to remove. |
Remarks
Removing a palette from the list might invalidate the configuration of any colorers referring to this palette provider.
SetActivePaletteIndex(Int32)
Changes the active palette index. It is user resposability to pass
a valid iPaletteIndex (between 0 and
GetNumPalettes() - 1)
Declaration
public void SetActivePaletteIndex(int iPaletteIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | iPaletteIndex | The value to set as active palette index. |
Update()
If any of the handled palette has been modified, or if the active palette selection has been changed, then also the provider is considered modified (and this will prompt the linked colorers to update).
Declaration
protected void Update()