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
Type | Description |
---|---|
bool | true 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
Type | Description |
---|---|
int | The current length (in pixels) of each crosshair line. |
GetThickness
Gets the current width (in pixels) of the crosshair line/s.
Returns
Type | Description |
---|---|
int | The 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
Type | Description |
---|---|
int | The 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
Type | Description |
---|---|
float | The current additional gap to apply to the crosshair. |
GetRotation
Gets the current rotation of the crosshair reticle.
Returns
Type | Description |
---|---|
float | The current rotation of the crosshair reticle. |
GetColor
Gets the current color of the crosshair.
Returns
Type | Description |
---|---|
Color | The current color of the crosshair. |
GetReticleSidesToDraw
Gets the current sides of the crosshair reticle to draw.
Returns
Type | Description |
---|---|
ReticleSide | The current sides of the crosshair reticle to draw. |
GetSizeNeeded
Gets the minimum size (in pixels) that the crosshair texture needs to be.
Returns
Type | Description |
---|---|
int | The minimum size (in pixels) that the crosshair texture needs to be. |
GetCircleSizeNeeded
Gets the size needed to draw circle crosshairs.
Returns
Type | Description |
---|---|
int | The 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
Type | Description |
---|---|
int | The current value of GetGap() + GetSpread() . |
GetCrosshair
Gets the current Crosshair instance.
Returns
Type | Description |
---|---|
Crosshair | The current Crosshair instance. |
SetSize
Sets the length (in pixels) of each crosshair line.
Parameters
Name | Type | Description |
---|---|---|
newSize | int | The gap to set the crosshair to have. If you use a value lower than 0 , this method sets the gap to 0 . |
redrawCrosshair | bool | Specifies 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
Name | Type | Description |
---|---|---|
newThickness | int | The thickness to set the crosshair to have. If you use a value lower than 1 , this method sets the thickness to 1 . |
redrawCrosshair | bool | Specifies 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
Name | Type | Description |
---|---|---|
newGap | int | The gap to set the crosshair to have. If you use a value lower than 0 , this method sets the gap to 0 . |
redrawCrosshair | bool | Specifies 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
Name | Type | Description |
---|---|---|
newCrosshair | Crosshair | The new crosshair properties to use. |
redrawCrosshair | bool | Specifies 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
Name | Type | Description |
---|---|---|
newSpread | float | The additional gap to apply to the crosshair. |
redrawCrosshair | bool | Specifies 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
Name | Type | Description |
---|---|---|
newRotation | float | The 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. |
redrawCrosshair | bool | Specifies 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
Name | Type | Description |
---|---|---|
newColor | Color | The color to set the crosshair to have. |
or
Name | Type | Description |
---|---|---|
channel | CrosshairColorChannel | The channel to set the color value for. |
value | int | The value to set the color channel to. Set this to a value between 0 and 255 . |
redrawCrosshair | bool | Specifies 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
Name | Type | Description |
---|---|---|
newReticleSidesToDraw | ReticleSide | Set the sides of the crosshair reticle to draw. |
redrawCrosshair | bool | Specifies 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. |