Static line crosshair
The static line crosshair is the simplest crosshair type. It provides the same customization as the dynamic line crosshair and is optimized for crosshairs that don't change every frame. It's generated as a Texture2D and applied to an Image component. This means if you change any crosshair properties, the crosshair texture must be regenerated. If you need to change crosshair properties every frame, you should use the dynamic line crosshair instead.
The static line crosshair is the one that's available in Simple Crosshair.
Create a static line crosshair
- Create a new GameObject.
- Attach the SimpleCrosshair component to the GameObject.
- In the Inspector for the
SimpleCrosshair
component, click Generate Crosshair GameObject. This generates a crosshair Canvas, if one doesn't already exist, and creates the other GameObjects and components required to render the crosshair. - To change the crosshair's appearance in the Editor, modify property values in the
SimpleCrosshair
component. To change the appearance of the crosshair at runtime, use the SimpleCrosshair component API.
Don't modify the crosshair GameObject that's generated by the SimpleCrosshair
component Inspector. To change crosshair properties, modify the SimpleCrosshair
component values instead.
Known issues
To provide optimal performance, the size of the crosshair Texture2D matches the minimum number of pixels required to display the crosshair. If you use an odd value for the crosshair line thickness, the size of the texture will be odd too and make the crosshair gap for each line half a pixel wider. To avoid this, use an even value for the crosshair line thickness. The dynamic line crosshair doesn't have this issue, so if you must use an odd value for the crosshair line thickness and need the gap to be correct, use the dynamic line crosshair instead.