Game.UI.InGame.PresetDescriptor
Assembly: Game
Namespace: Game.UI.InGame
Type: public class
Base: System.Object
Summary:
PresetDescriptor represents a named preset for Photo/Camera settings used by the in-game cinematic/photo mode system. It stores an ordered list of option identifiers (option keys/IDs shown in UI) and a mapping from PhotoModeProperty (a property enum from Game.Rendering.CinematicCamera) to an array of float values — one value per option. The arrays in the values dictionary are expected to be the same length as the options list so each option has a corresponding value for each tracked property.
Fields
-
private System.Collections.Generic.List<string> m_OptionsId = new List<string>()
Backs the ordered list of option identifiers for the preset. Items are added with AddOption/AddOptions. The list is exposed as a read-only collection via the optionsId property. This field allows duplicate optionIds (no deduplication in code). -
private System.Collections.Generic.Dictionary<Game.Rendering.CinematicCamera.PhotoModeProperty, float[]> m_Values = new Dictionary<PhotoModeProperty, float[]>()
Maps each PhotoModeProperty to an array of float values, where each array element corresponds to an option in m_OptionsId by index. The dictionary is exposed as a read-only dictionary via the values property. Values are added with AddValues which uses Dictionary.Add (will throw if the key already exists).
Properties
-
public System.Collections.Generic.IReadOnlyCollection<string> optionsId { get; }
Read-only view of the option ID list (backed by m_OptionsId). Use this to enumerate option identifiers and obtain the expected length for property value arrays. -
public System.Collections.Generic.IReadOnlyDictionary<Game.Rendering.CinematicCamera.PhotoModeProperty, float[]> values { get; }
Read-only view of the mapping from PhotoModeProperty to value arrays (backed by m_Values). Each float[] should have the same length as optionsId.Count.
Constructors
public PresetDescriptor()
The class has the default parameterless constructor (no explicit constructor declared in source). Field initializers already create the internal collections. No additional initialization logic is required.
Methods
-
public bool Validate()
Checks that every float[] stored in m_Values has a length equal to the number of option IDs in m_OptionsId. Returns true if all arrays match the options count; returns false if any array length differs. Use this to ensure the preset is consistent before applying or serializing it. -
public void AddOptions(System.Collections.Generic.IEnumerable<string> optionIds)
Adds multiple option identifiers to the options list by calling AddOption for each element in the provided enumerable. Preserves order of the provided sequence. -
public void AddOption(string optionId)
Adds a single option identifier to the end of the options list (m_OptionsId.Add). Does not validate uniqueness or content of the ID. -
public void AddValues(Game.Rendering.CinematicCamera.PhotoModeProperty targetProperty, float[] values)
Adds a mapping from the given PhotoModeProperty to the supplied float[] into the m_Values dictionary using Dictionary.Add. The method does not validate the length of the supplied values array against the current options count — call Validate() to confirm consistency. If the key already exists, Dictionary.Add will throw an ArgumentException.
Notes and considerations: - The class does not perform defensive copying; callers should avoid mutating float[] arrays after adding them if immutability is desired. - Not thread-safe — concurrent modification of collections may cause undefined behavior. - There is no built-in removal or update method for values or options in this class.
Usage Example
using Game.UI.InGame;
using Game.Rendering.CinematicCamera;
// Create a preset descriptor
var preset = new PresetDescriptor();
// Add option identifiers (order matters; each property array must match this length)
preset.AddOptions(new[] { "Low", "Medium", "High" });
// Add property values for a PhotoModeProperty (array length must match options count)
preset.AddValues(PhotoModeProperty.Exposure, new float[] { 0.5f, 1.0f, 1.5f });
preset.AddValues(PhotoModeProperty.Contrast, new float[] { 0.8f, 1.0f, 1.2f });
// Validate before using
if (!preset.Validate())
{
// Handle inconsistent preset (mismatched array lengths)
}
// Read values
foreach (var optionId in preset.optionsId)
{
// ...
}
if (preset.values.TryGetValue(PhotoModeProperty.Exposure, out var exposures))
{
// exposures[i] corresponds to option at index i
}