Swipe Input
codemaker2015
$0.0
(no ratings)
Date |
Price |
---|---|
日時 |
価格($) |
03/27(2024) |
0.0 |
11/25(2024) |
0.0 |
Jump AssetStore
This package allows users to perform various actions by swiping in different directions - up, down, left, and right.Swipe Input is a powerful gesture-based interaction system designed to enhance user experience in mobile applications and games. With its two core scripts, SwipeInput and SwipeInputController, developers can effortlessly integrate tap and swipe gestures into their projects, adding intuitive controls and dynamic interactions.Core Features:Tap and swipe gesture detection for seamless user interaction.Customizable offset parameters for precise gesture recognition.Easy integration into Unity projects with clear documentation and usage instructions.Flexibility to enable or disable tap and swipe gestures as needed.Real-time debugging capabilities for monitoring gesture detection and processing.The system consists of two scripts: SwipeInput (the core module) and SwipeInputController(the usage script).SwipeInput ScriptCore Variables- tapPositions: An array of Vector2 to store the positions of two consecutive taps.- swipePositions: An array of Vector2 to store the positions of two consecutive swipes.- offsetTap: A float representing the allowed offset for a tap gesture.- offsetSwipe: A float representing the allowed offset for a swipe gesture.- fTapAllowed: A boolean flag indicating whether tap gestures are allowed.- fSwipeAllowed: A boolean flag indicating whether swipe gestures are allowed.- tempX and tempY: Temporary variables to store the differences in x and y coordinates during gesture processing.Core Methods- ProcessTouches(): Handles the touch input and updates the tap and swipe positions based on touch phases.- ResetPositions(): Resets tap and swipe positions and flags.Control Methods- Tap(): Detects tap gestures by comparing the distance between two tap positions with the specified offset.- SwipeLeft(), SwipeRight(), SwipeUp(), SwipeDown(): Detects swipe gestures in the respective directions by comparing the distance between two swipe positions with the specified offset.SwipeInputController ScriptVariables- Debug: A reference to a Text component for displaying debug information.Methods- Start(): Initializes the Debug variable by finding the Text component.- Update(): Processes touch input using SwipeInput.ProcessTouches() and performs actions based on detected gestures. Updates the object's position accordingly.Usage1. Attach the SwipeInputController script to the GameObject you want to control with swipe gestures.2. Create a UI Text object named "Debug" to display debug information.3. The system automatically detects swipe gestures and updates the object's position based on the detected gesture.