Skip to main content

Demo scenes

The asset includes demo scenes and example scripts that show how to use the crosshair API. You can find them in the Assets/Simple Crosshair Plus/Demo Scenes folder. The scripts that they use are in the Assets/Simple Crosshair Plus/Scripts/Example folder.

CrosshairModificationExample

The Dynamic Circle, Dynamic Line, and Static Line folders all contain a demo scene called CrosshairModificationExample. This scene shows how to use the unified SimpleCrosshairBase API to modify the appearance of each crosshair type at runtime. See the ModifyCrosshairAPIExample script (attached to the API Example GameObject in the scene) to see the implementation.

To use the demo scene, enter Play mode then use the following controls to change the appearance of the crosshair.

KeyFunction
QIncrease the crosshair's gap.
ADecrease the crosshair's gap.
WIncrease the crosshair's thickness.
SDecrease the crosshair's thickness.
EIncrease the crosshair's size.
DDecrease the crosshair's size.
RRotate the crosshair clockwise.
FRotate the crosshair counter-clockwise.
SpaceSet the crosshair to a random color.
1Toggle the rendering of the top reticle.
2Toggle the rendering of the right reticle.
3Toggle the rendering of the bottom reticle.
4Toggle the rendering of the left reticle.

CrosshairSpreadExample

The Dynamic Circle and Dynamic Line folders contain a demo scene called CrosshairSpreadExample. This scene shows how to use the unified SimpleCrosshairBase API to modify the spread of dynamic crosshairs at runtime. See the DynamicCrosshairSpreadExample script (attached to the API Example GameObject in the scene) to see the implementation.

In your game, the crosshair spread should derive from the accuracy of the weapon so where the bullets go and the crosshair gap match. This scene simulates a weapon firing and increases the spread with every shot. It then decreases the spread over time.

To use the demo scene, enter Play mode then click the left mouse button to increase the crosshair spread.

ChangeCrosshairTypeExample

The ChangeCrosshairTypeExample scene shows how to change the crosshair type at runtime. Each crosshair type requires a different GameObject and component setup to render the crosshair. To switch crosshair types, you must clear and destroy the current crosshair then create and initialise a new crosshair. The API example script shows you how to do this while also preserving the crosshair settings. See the ChangeCrosshairTypeExample script (attached to the API Example GameObject in the scene) to see the implementation.

To use the demo scene, enter Play mode then use the following controls to change the crosshair type.

  • Press the 1 key to change the crosshair type to a static line crosshair.
  • Press the 2 key to change the crosshair type to a dynamic line crosshair.
  • Press the 3 key to change the crosshair type to a dynamic circle crosshair.