Game.Rendering.CinematicCamera.PhotoModeUtils
Assembly: Assembly-CSharp (game)
Namespace: Game.Rendering.CinematicCamera
Type: public static class PhotoModeUtils
Base: System.Object
Summary:
Utility helpers for Cities: Skylines 2 photo mode / cinematic camera UI. PhotoModeUtils provides a collection of BindProperty overloads to create PhotoModeProperty entries (single-value and multi-component) from various parameter types (FloatParameter, Vector2/3/4Parameter, ColorParameter, Clamped/Min/Overridable parameters, Enums, BoolParameter, OverridableLensProperty, VolumeParameter, etc.). It uses expression-tree based reflection (ExtractMember) to extract field/property targets and build consistent PhotoModeProperty objects that can be used by the mod UI to drive and display parameter values, overrides, min/max bounds, reset behavior and availability. Also contains small helpers for enum rounding, boolean/float conversion, and preset creation.
Fields
- This type declares no instance or public fields.
All functionality is exposed through static methods. Internal state is not stored on this class.
Properties
- This type declares no properties.
Constructors
- This static class has no user-defined constructors.
Methods
-
private static T ExtractMember<T>(Expression<Func<T>> expression, out string name)
Internal helper that walks nested MemberExpression(s) in the provided expression to extract a field value and create an id string (name). Used by BindProperty overloads to obtain the runtime parameter object referenced by the expression and to build a unique id for UI binding. -
private static T ExtractMember<T>(Expression<Func<T>> expression, out string name, out GameSystemBase systemBase)
Variant used when the extracted member belongs to a GameSystemBase instance. Returns the property value and also outputs the GameSystemBase instance so callers can call system.Update() when overrides are changed. -
public static PhotoModeProperty BindPropertyW(string tab, Expression<Func<Vector4Parameter>> expression, float min, float max, Func<bool> isAvailable = null)
Convenience overload to bind the .w component of a Vector4Parameter. -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<FloatParameter>> expression, Func<bool> isAvailable = null)
Bind a FloatParameter to a PhotoModeProperty (no explicit min/max). -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<FloatParameter>> expression, float min, float max, Func<bool> isAvailable = null)
Bind a FloatParameter to a PhotoModeProperty with explicit min/max functions. -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<MinFloatParameter>> expression, Func<bool> isAvailable = null)
Bind a MinFloatParameter (exposes min getter). -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<Vector4Parameter>> expression, Func<Vector4, float> getter, Func<Vector4, float, Vector4> setter, float min, float max, Func<bool> isAvailable = null)
Generic Vector4 component binder: use getter to pick a component and setter to write component back. -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<OverridableProperty<float>>> expression, Func<bool> isAvailable = null)
Bind an OverridablePropertyand call system.Update() when override/overrideState is changed. Uses ExtractMember overload that outputs GameSystemBase. -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<ClampedFloatParameter>> expression, Func<bool> isAvailable = null)
Bind a ClampedFloatParameter (reads min/max from parameter). -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<ClampedIntParameter>> expression, Func<bool> isAvailable = null)
Bind a ClampedIntParameter (value is exposed as float for UI; override uses int cast). -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<OverridableLensProperty<float>>> expression, float min, float max, Func<float, float> from = null, Func<float, float> to = null, Func<bool> isAvailable = null)
Bind a lens float property with optional mapping functions (from/to) and explicit bounds. -
public static PhotoModeProperty GroupTitle(string tab, string name)
Create a PhotoModeProperty that acts as a group/title entry (id = name, group = tab). -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<OverridableLensProperty<float>>> expression, Func<float> min, Func<float> max, Func<float, float> from = null, Func<float, float> to = null, Func<bool> isAvailable = null)
Same as above but accepts dynamic min/max suppliers. -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<OverridableLensProperty<int>>> expression, int min, int max, Func<bool> isAvailable = null)
Bind lens int property with bounds; UI uses integer steps (fractionDigits = 0). -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<OverridableLensProperty<int>>> expression, int min, Func<bool> isAvailable = null)
Bind lens int property with single-sided bound. -
public static PhotoModeProperty BindProperty<T>(string tab, Expression<Func<VolumeParameter<T>>> expression, Func<bool> isAvailable = null) where T : Enum
Bind an enum stored in a VolumeParameter. Converts between float slider position and nearest enum value. -
public static PhotoModeProperty BindProperty<T>(string tab, Expression<Func<OverridableLensProperty<T>>> expression, Func<bool> isAvailable = null) where T : Enum
Bind an enum on an OverridableLensProperty. -
public static T FindClosestEnumValue<T>(float value) where T : Enum
Helper that converts from a float to the closest underlying integer enum value (returns enum instance). Used by enum binders. -
public static PhotoModeProperty BindProperty(string tab, Expression<Func<BoolParameter>> expression, Func<bool> isAvailable = null)
Bind a BoolParameter and use a float-based UI (0/1) with overrideControl set to Checkbox. -
public static bool FloatToBoolean(float value)
Converts a float to bool (rounds to nearest int, non-zero => true). -
public static float BooleanToFloat(bool value)
Converts a bool to float (true => 1f, false => 0f). -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<ColorParameter>> expression)
Binds ColorParameter to 3 (r,g,b) or 4 (r,g,b,a) PhotoModeProperty components. Honors HDR (max is Infinity) and showAlpha flag. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<Vector2Parameter>> expression, float min, float max)
Bind Vector2Parameter with same min/max for both components. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<Vector2Parameter>> expression, Bounds1 bounds)
Bind Vector2Parameter using Bounds1 values. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<Vector2Parameter>> expression, Bounds1 xBounds, Bounds1 yBounds)
Bind Vector2Parameter with distinct bounds per component. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<Vector2Parameter>> expression)
Bind Vector2Parameter without explicit bounds. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<Vector3Parameter>> expression, float min, float max)
Bind Vector3Parameter with same min/max for all components. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<Vector3Parameter>> expression, Bounds1 bounds)
Bind Vector3Parameter using Bounds1 for all components. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<Vector3Parameter>> expression, Bounds1 xBounds, Bounds1 yBounds, Bounds1 zBounds)
Bind Vector3Parameter with distinct bounds per component. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<Vector3Parameter>> expression)
Bind Vector3Parameter without explicit bounds. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<OverridableLensProperty<Vector2>>> expression)
Bind overridable lens Vector2 property (x, y) with Sync reset behavior. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<OverridableLensProperty<Vector2>>> expression, float min = 0f, float max = 0f)
Convenience overload taking min/max floats. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<OverridableLensProperty<Vector2>>> expression, Bounds1 bounds)
Vector2 overridable lens with bounds. -
public static PhotoModeProperty[] BindProperty(string tab, Expression<Func<OverridableLensProperty<Vector2>>> expression, Bounds1 xBounds, Bounds1 yBounds)
Vector2 overridable lens with separate bounds. -
public static IEnumerable<PhotoModeProperty> ExtractMultiPropertyComponents(PhotoModeProperty property, IDictionary<string, PhotoModeProperty> allProperties)
If property.id contains a "/" (multi-component), yields all properties in the dictionary that start with the same base id (prefix before the component suffix). Otherwise yields the single property. Useful to treat grouped components (e.g., "color/r","color/g","color/b") as a logical group. -
public static string ExtractPropertyID(PhotoModeProperty property)
Returns the base id by stripping any component suffix after the first "/" (e.g., "foo/x" -> "foo"). -
public static PhotoModeUIPreset CreatePreset(string name, PhotoModeProperty injectionProperty, PhotoModeProperty[] targetProperties, string[] options, Vector2[] values)
Create a PhotoModeUIPreset backed by a PresetDescriptor. Designed for two-component targetProperties (Vector2) — it validates the descriptor and throws if targetProperties length is not 2 or descriptor is invalid. Values array maps to options.
Usage Example
// Example: Bind a float parameter from a post-process volume to the photo mode UI
// (assumes 'SomeVolume' is a class exposing a VolumeParameter<FloatParameter> field)
using Game.Rendering.CinematicCamera;
using UnityEngine;
// Bind a single float parameter (no explicit min/max)
PhotoModeProperty exposureProp = PhotoModeUtils.BindProperty(
"PostProcessing",
() => SomeVolume.settings.exposure, // expression pointing to the parameter
isAvailable: () => true // optional availability predicate
);
// Bind a color parameter (creates multiple properties: r/g/b[,a])
PhotoModeProperty[] skyColorProps = PhotoModeUtils.BindProperty(
"Sky",
() => SomeVolume.settings.skyColor
);
// Create a simple preset for two target properties (expects two component properties like position/x and position/y)
PhotoModeUIPreset preset = PhotoModeUtils.CreatePreset(
"PresetName",
injectionProperty: exposureProp,
targetProperties: new[] { /* prop for x */, /* prop for y */ },
options: new[] { "Low", "Medium", "High" },
values: new[] { new Vector2(0f, 0f), new Vector2(0.5f, 0.5f), new Vector2(1f, 1f) }
);
Notes:
- BindProperty uses expression trees to obtain the target parameter instance and to create an id string used by the UI. The expression must reference a field/property path accessible at runtime.
- Many overloads accept Func