Class ClientCrosshairSettings
The crosshair's appearance: whether it is drawn, what shape it is, how large, and how strongly.
public static class ClientCrosshairSettings
- Inheritance
-
ClientCrosshairSettings
- Inherited Members
Remarks
Colour is deliberately absent. It is already a themed colour —
ColorNames carries Crosshair, and the UI tab's colour list
edits it — so exposing a second control for the same value would give a player two places
to set one colour and no rule about which wins.
Why the settings live here rather than on the panel.
UITKCrosshair is a panel: it does not exist until the HUD is built, and its
OnStarting re-runs whenever the visual tree is replaced. A panel that owned the
defaults would be the only thing that knew them, and every consumer would have to wait for
it. These are plain reads off ClientSettings, so the options panel and the
crosshair can both answer "what size is it" without either of them existing yet.
Fields
CircleClass
USS class applied for Circle.
public const string CircleClass = "crosshair-icon--circle"
Field Value
CrossClass
USS class applied for Cross.
public const string CrossClass = "crosshair-icon--cross"
Field Value
DefaultEnabled
Whether a fresh install draws a crosshair.
public const bool DefaultEnabled = true
Field Value
DefaultOpacity
Opacity a fresh install uses.
public const float DefaultOpacity = 1
Field Value
DefaultSize
Edge length a fresh install uses, in panel points.
public const float DefaultSize = 8
Field Value
Remarks
Eight, which is what UICrosshair.uss authors and what the uGUI crosshair drew
before the UI Toolkit port. The default is repeated here rather than left to the
stylesheet because this value is also what the options slider shows before the player
has ever moved it, and a slider that starts somewhere other than the crosshair's actual
size is a control that lies about the state it is editing.
DefaultStyle
The shape a fresh install uses.
public const ClientCrosshairSettings.CrosshairStyle DefaultStyle = Cross
Field Value
DotClass
USS class applied for Dot.
public const string DotClass = "crosshair-icon--dot"
Field Value
MaximumOpacity
Strongest crosshair offered.
public const float MaximumOpacity = 1
Field Value
MaximumSize
Largest crosshair offered, in panel points.
public const float MaximumSize = 32
Field Value
Remarks
Thirty-two. A crosshair is a sighting mark, and past this it stops marking a point and starts covering the thing being aimed at — which is the failure the 8px retune in UICrosshair.uss already corrected once.
MinimumOpacity
Faintest crosshair offered.
public const float MinimumOpacity = 0.1
Field Value
Remarks
Not zero. Zero is "no crosshair", which the enable toggle already says, and a slider that can silently reproduce a toggle's off state gives the player two ways to reach one result and no way to tell which one they are in.
MinimumSize
Smallest crosshair offered, in panel points.
public const float MinimumSize = 4
Field Value
Remarks
Four: below that the shape is indistinguishable from a stuck pixel.
StyleClasses
Every style class, so a rebuild can clear the ones that do not apply.
public static readonly string[] StyleClasses
Field Value
- string[]
StyleLabels
Labels shown in the options panel, in ClientCrosshairSettings.CrosshairStyle order.
public static readonly string[] StyleLabels
Field Value
- string[]
Properties
Enabled
Whether the crosshair is drawn at all.
public static bool Enabled { get; }
Property Value
Opacity
The chosen opacity.
public static float Opacity { get; }
Property Value
Size
The chosen edge length, in panel points.
public static float Size { get; }
Property Value
Style
The chosen shape, clamped to a style this build knows.
public static ClientCrosshairSettings.CrosshairStyle Style { get; }
Property Value
Methods
SetEnabled(bool)
Writes whether the crosshair is drawn and notifies the panel.
public static void SetEnabled(bool value)
Parameters
valuebool
SetOpacity(float)
Writes the opacity and notifies the panel.
public static void SetOpacity(float value)
Parameters
valuefloat
SetSize(float)
Writes the edge length and notifies the panel.
public static void SetSize(float value)
Parameters
valuefloat
SetStyle(CrosshairStyle)
Writes the shape and notifies the panel.
public static void SetStyle(ClientCrosshairSettings.CrosshairStyle value)
Parameters
Events
OnChanged
Raised when any crosshair setting changes.
public static event Action OnChanged
Event Type
Remarks
The crosshair panel subscribes; the options panel raises. Neither holds a reference to the other, which matters because the options panel can be open in a scene where the HUD is not loaded at all.