Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
When touches are created by Input Sources the library needs to find out if these touches actually hit anything in the scene. TouchScript does this using a sorted list of layers, i.e. objects extending TouchLayer class.
A target of a touch is a Transform in the scene.
Every layer from top to bottom is asked whether a new touch hits anything in this layer. If it does, this target is assigned to the touch and the loop stops. Layers also get notified of all touch-related events (began, moved, ended, cancelled) and can route this events to other subsystems. This is how ScaleformLayer used to work.
Working with layers
Right now TouchScript has the following layers:
- StandardLayer which unifies raycasting into 3d, 2d and UI objects,
- FullscreenLayer which when attached to a camera represents a fullscreen plane parallel to camera's display plane.
Order and instantiation logic
Sometimes it's important to understand how layers you create manually or from a script register themselves with the system. When a scene starts events happen in this order:
- (OnEnable) Everything defined (and manually sorted) on TouchManager component is registered in correct order.
- (EndOfFrame) All layers try to register themselves. Nothing happens if they were already registered in appropriate order by TouchManager. Order here is undefined.
- (NextFrame) If after this there are no layers in the scene, a StandardLayer is created and assigned to
Implementing your own layer
If you want to implement your own layer you can use StandardLayer as example.