Skip to main content

ReticleLines

Represents the GameObjects and components required to render a dynamic line crosshair.

info

Unless you want to extend the functionality of the dynamic line crosshair, you shouldn't need to use this class directly. Instead, to change the look of the crosshair, use the DynamicLineCrosshair API.

Methods

Clear

Destroys all the GameObjects required to render the crosshair.


Initialise

Creates all the GameObjects required to render the crosshair. This generates four GameObjects, one per side of the crosshair.


IsValid

Indicates whether the crosshair is setup correctly.

Returns

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

Indexer

An indexer that provides the RectTransforms associated with each side of the reticle.

Parameters

NameTypeDescription
lineReticleSideThe side of the reticle to get the RectTransform of.

Returns

TypeDescription
RectTransformThe RectTransform that represents the passed in side of the reticle.

Example

The following example uses this indexer to access each side of the reticle and set its color.

private void ColorCrosshairReticle(ReticleLines reticle, Color color)
{
ReticleSideUtility.ForEach((ReticleSide line) =>
{
reticle[line].GetComponent<Image>().color = color;
});
}