Skip to main content

Dynamic line crosshair

The dynamic line crosshair looks the same as the static line crosshair but is optimized to change every frame. It's generated as a group of GameObjects, one per line, with attached Image components. They can move, resize, and change color every frame with a negligible impact on performance.

Dynamic line crosshair dynamic spread

Create a dynamic line crosshair

  1. Create a new GameObject.
  2. Attach the SimpleDynamicLineCrosshair component to the GameObject.
  3. In the Inspector for the SimpleDynamicLineCrosshair 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.
  4. To change the crosshair's appearance in the Editor, modify property values in the SimpleDynamicLineCrosshair component. To change the appearance of the crosshair at runtime, use the SimpleDynamicLineCrosshair component API.
caution

Don't modify the crosshair GameObject that's generated by the SimpleDynamicLineCrosshair component Inspector. To change crosshair properties, modify the SimpleDynamicLineCrosshair component values instead.