Selecting Objects
This page details how to enable users to select game objects in the scene with mouse or touch input when using the Leia plugin.
Sample Scene: Assets/Leia/Examples/WorldSpaceUI/SelectingObjects
To start, we need to raycast from the user's head position, given by:
in the direction of the point on the screen where the user clicked or tapped, which is given by:
Mouse Input:
Touch Input:
The example code below will print a debug of which object in the scene the user clicked on.
Example code:
To use it, create an empty game object in the scene and attach this script to it.
You should now be able to click on objects in the scene and see the name of the clicked object printed in the Unity debug console window.
Last updated