Skip to main content

SimpleCrosshairBase

The base class for all crosshair types. It provides a unified API to interact and modify all crosshair types.

Methods

GenerateCrosshair

A virtual method that derived classes implement to generate the crosshair based on the current settings. You can use this method to update the visible crosshair after you change any of the settings. Each Set... method in this class has a redrawCrosshair parameter which, if set to true, causes the Set... method to call this method after it sets the value. If you call multiple Set... methods subsequently, it's best practice to set redrawCrosshair to false and then call this method manually afterward.


GenerateCrosshairGameObject

A virtual method that derived classes implement to generate the GameObjects and components required to render the crosshair.


CrosshairParentSet

A virtual method that derived classes implement to indicate whether the GameObjects and components are setup ready to render the crosshair.

Returns

TypeDescription
booltrue if the crosshair is setup correctly. Otherwise, returns false.

GetSize

Gets the current length (in pixels) of each crosshair line. This is only relevant for line crosshairs.

Returns

TypeDescription
intThe current length (in pixels) of each crosshair line.

GetThickness

Gets the current width (in pixels) of the crosshair line/s.

Returns

TypeDescription
intThe current width (in pixels) of the crosshair line/s.

GetGap

Gets the current distance (in pixels) from the center of the crosshair to the beginning of the crosshair line/s.

Returns

TypeDescription
intThe current distance (in pixels) from the center of the crosshair to the beginning of the crosshair line/s.

GetSpread

Gets the current additional gap to apply to the crosshair. This is useful if you want to apply a temporary additional gap and still want to return to the original gap value.

Returns

TypeDescription
floatThe current additional gap to apply to the crosshair.

GetRotation

Gets the current rotation of the crosshair reticle.

Returns

TypeDescription
floatThe current rotation of the crosshair reticle.

GetColor

Gets the current color of the crosshair.

Returns

TypeDescription
ColorThe current color of the crosshair.

GetReticleSidesToDraw

Gets the current sides of the crosshair reticle to draw.

Returns

TypeDescription
ReticleSideThe current sides of the crosshair reticle to draw.

GetSizeNeeded

Gets the minimum size (in pixels) that the crosshair texture needs to be.

Returns

TypeDescription
intThe minimum size (in pixels) that the crosshair texture needs to be.

GetCircleSizeNeeded

Gets the size needed to draw circle crosshairs.

Returns

TypeDescription
intThe size needed to draw circle crosshairs.

GetGapPlusSpread

Gets the current value of GetGap() + GetSpread(). This is the current full distance from the center of the crosshair to the beginning of the crosshair line/s.

Returns

TypeDescription
intThe current value of GetGap() + GetSpread().

GetCrosshair

Gets the current Crosshair instance.

Returns

TypeDescription
CrosshairThe current Crosshair instance.

SetSize

Sets the length (in pixels) of each crosshair line.

Parameters

NameTypeDescription
newSizeintThe gap to set the crosshair to have. If you use a value lower than 0, this method sets the gap to 0.
redrawCrosshairboolSpecifies whether to redraw the crosshair with the updated value. If you set this to true, the generator redraws the crosshair. If you set this to false, you can still use GenerateCrosshair() to draw the crosshair with the updated value.

SetThickness

Sets the width (in pixels) of the crosshair line/s.

Parameters

NameTypeDescription
newThicknessintThe thickness to set the crosshair to have. If you use a value lower than 1, this method sets the thickness to 1.
redrawCrosshairboolSpecifies whether to redraw the crosshair with the updated value. If you set this to true, the generator redraws the crosshair. If you set this to false, you can still use GenerateCrosshair() to draw the crosshair with the updated value.

SetGap

Sets the distance (in pixels) from the center of the crosshair to the beginning of the crosshair line/s.

Parameters

NameTypeDescription
newGapintThe gap to set the crosshair to have. If you use a value lower than 0, this method sets the gap to 0.
redrawCrosshairboolSpecifies whether to redraw the crosshair with the updated value. If you set this to true, the generator redraws the crosshair. If you set this to false, you can still use GenerateCrosshair() to draw the crosshair with the updated value.

SetCrosshair

Overrides the current crosshair properties with the passed in crosshair properties.

Parameters

NameTypeDescription
newCrosshairCrosshairThe new crosshair properties to use.
redrawCrosshairboolSpecifies whether to redraw the crosshair with the updated value. If you set this to true, the generator redraws the crosshair. If you set this to false, you can still use GenerateCrosshair() to draw the crosshair with the updated value.

SetSpread

Sets the additional gap to apply to the crosshair.

Parameters

NameTypeDescription
newSpreadfloatThe additional gap to apply to the crosshair.
redrawCrosshairboolSpecifies whether to redraw the crosshair with the updated value. If you set this to true, the generator redraws the crosshair. If you set this to false, you can still use GenerateCrosshair() to draw the crosshair with the updated value.

SetRotation

Sets the rotation of the crosshair reticle.

Parameters

NameTypeDescription
newRotationfloatThe rotation to set the crosshair to have. If you use a value lower than 0, this method sets the rotation to 0. If you use a value higher than 360, this method loops to value using Mathf.Repeat.
redrawCrosshairboolSpecifies whether to redraw the crosshair with the updated value. If you set this to true, the generator redraws the crosshair. If you set this to false, you can still use GenerateCrosshair() to draw the crosshair with the updated value.

SetColor

Sets the color of the crosshair.

Parameters

NameTypeDescription
newColorColorThe color to set the crosshair to have.

or

NameTypeDescription
channelCrosshairColorChannelThe channel to set the color value for.
valueintThe value to set the color channel to. Set this to a value between 0 and 255.
redrawCrosshairboolSpecifies whether to redraw the crosshair with the updated value. If you set this to true, the generator redraws the crosshair. If you set this to false, you can still use GenerateCrosshair() to draw the crosshair with the updated value.

SetReticleSidesToDraw

Sets the sides of the crosshair reticle to draw.

Parameters

NameTypeDescription
newReticleSidesToDrawReticleSideSet the sides of the crosshair reticle to draw.
redrawCrosshairboolSpecifies whether to redraw the crosshair with the updated value. If you set this to true, the generator redraws the crosshair. If you set this to false, you can still use GenerateCrosshair() to draw the crosshair with the updated value.