Class ViewModeCollectionConfigAsset
Represents a configuration that provides a collection of available view mode configuration items
Implements
Inherited Members
Namespace: Fwt.HexTerrains.ViewModes.Data
Assembly: fwt.hexterrains.dll
Syntax
[CreateAssetMenu(menuName = "Fwt/HexTerrains/View Modes/ViewMode Collection config", fileName = "ViewModeCollectionConfig")]
public class ViewModeCollectionConfigAsset : ScriptableObject, IViewModeCollectionConfig
Fields
_viewModeConfigByName
Stores view mode configuration assets indexed by their associated names. If you change ViewModes collection, you should update this dictionary accordingly by calling UpdateCache() to maintain consistency between the list and the dictionary.
Declaration
protected Dictionary<string, ViewModeConfigAssetBase> _viewModeConfigByName
Field Value
| Type | Description |
|---|---|
| Dictionary<string, ViewModeConfigAssetBase> |
Remarks
This dictionary enables efficient lookup and management of view mode configurations by name. Derived classes can use this collection to retrieve or update specific view mode configurations as needed.
_viewModeIndexByName
Declaration
protected Dictionary<string, int> _viewModeIndexByName
Field Value
| Type | Description |
|---|---|
| Dictionary<string, int> |
_viewModes
Declaration
[Tooltip("The collection of available view mode configuration assets for this component.")]
[SerializeField]
protected List<ViewModeConfigAssetBase> _viewModes
Field Value
| Type | Description |
|---|---|
| List<ViewModeConfigAssetBase> |
Properties
ViewModes
Gets or sets the collection of view mode configurations available to the application.
Declaration
public List<ViewModeConfigAssetBase> ViewModes { get; set; }
Property Value
| Type | Description |
|---|---|
| List<ViewModeConfigAssetBase> |
Remarks
The list determines which view modes can be presented or selected by users. Modifying this collection affects the available view options at runtime.
Methods
GetViewMode(string)
Retrieves the index of the specified view mode by its name.
Declaration
public virtual int GetViewMode(string viewModeName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | viewModeName | The name of the view mode to locate. This parameter cannot be null or empty. |
Returns
| Type | Description |
|---|---|
| int | The zero-based index of the view mode if found; otherwise, -1. |
Remarks
If the view mode configuration is not cached, the method updates the cache before searching. The comparison of the view mode name is case-sensitive.
GetViewModeConfig(int)
Retrieves the configuration settings for the specified view mode (by ViewMode index).
Declaration
public virtual IViewModeConfig GetViewModeConfig(int viewModeIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | viewModeIndex | The zero-based index of the view mode for which to obtain configuration settings. Must be within the range of available view modes. |
Returns
| Type | Description |
|---|---|
| IViewModeConfig | An object that provides configuration details for the specified view mode. |
GetViewModeConfig(string)
Retrieves the configuration settings for the specified view mode (by ViewMode name set in config).
Declaration
public virtual IViewModeConfig GetViewModeConfig(string viewModeName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | viewModeName | The name of the view mode for which to retrieve the configuration. |
Returns
| Type | Description |
|---|---|
| IViewModeConfig | An instance of IViewModeConfig containing the configuration settings for the specified view mode, or null if the view mode is not found. |
Remarks
Ensure that the specified view mode name corresponds to an existing view mode configuration.
GetViewModeConfig(string, out int)
Retrieves the configuration settings for the specified view mode (by ViewMode name set in config). out parameter viewMode is the index of the view mode with the specified name.
Declaration
public virtual IViewModeConfig GetViewModeConfig(string viewModeName, out int viewMode)
Parameters
| Type | Name | Description |
|---|---|---|
| string | viewModeName | The name of the view mode for which to retrieve the configuration. |
| int | viewMode |
Returns
| Type | Description |
|---|---|
| IViewModeConfig | An instance of IViewModeConfig containing the configuration settings for the specified view mode, or null if the view mode is not found. |
Remarks
Ensure that the specified view mode name corresponds to an existing view mode configuration.
UpdateCache()
Updates the internal cache of view modes to reflect the current collection of view mode configurations.
Declaration
public virtual void UpdateCache()
Remarks
Call this method after modifying the list of view modes to ensure that the cache remains accurate. Only view modes with non-empty names are included in the cache.