com.amanotes.magictilescore 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +240 -0
- package/CHANGELOG.md.meta +7 -0
- package/Docs/Class-Hierarchy.md +729 -0
- package/Docs/Class-Hierarchy.md.meta +7 -0
- package/Docs/Component-Architecture.md +43 -0
- package/Docs/Component-Architecture.md.meta +7 -0
- package/Docs/File-Structure.md +327 -0
- package/Docs/File-Structure.md.meta +7 -0
- package/Docs/Game-Architecture.md +41 -0
- package/Docs/Game-Architecture.md.meta +7 -0
- package/Docs/Input-System-Guide.md +419 -0
- package/Docs/Input-System-Guide.md.meta +7 -0
- package/Docs/Knot-System-Guide.md +309 -0
- package/Docs/Knot-System-Guide.md.meta +7 -0
- package/Docs/Meta-System-Guide.md +249 -0
- package/Docs/Meta-System-Guide.md.meta +7 -0
- package/Docs/New-Game-Checklist.md +102 -0
- package/Docs/New-Game-Checklist.md.meta +7 -0
- package/Docs/README.md +37 -0
- package/Docs/README.md.meta +7 -0
- package/Docs/RhythmCore-Architecture.md +373 -0
- package/Docs/RhythmCore-Architecture.md.meta +7 -0
- package/Docs/RhythmCore-Customize-Guide.md +391 -0
- package/Docs/RhythmCore-Customize-Guide.md.meta +7 -0
- package/Docs/Understanding-Rhythm-Core.md +483 -0
- package/Docs/Understanding-Rhythm-Core.md.meta +7 -0
- package/Docs/VisualWarp-System-Guide.md +377 -0
- package/Docs/VisualWarp-System-Guide.md.meta +7 -0
- package/Docs/Widget2D-System-Guide.md +450 -0
- package/Docs/Widget2D-System-Guide.md.meta +7 -0
- package/Docs.meta +8 -0
- package/Editor/AdjustHueEditor.cs +90 -0
- package/Editor/AdjustHueEditor.cs.meta +11 -0
- package/Editor/ClassInstanceDrawer.cs +256 -0
- package/Editor/ClassInstanceDrawer.cs.meta +11 -0
- package/Editor/CollapsibleGroupEditor.cs +142 -0
- package/Editor/CollapsibleGroupEditor.cs.meta +11 -0
- package/Editor/ListSongNoteEditor.cs +317 -0
- package/Editor/ListSongNoteEditor.cs.meta +11 -0
- package/Editor/MagicTilesCore.Editor.asmdef +20 -0
- package/Editor/MagicTilesCore.Editor.asmdef.meta +7 -0
- package/Editor/MetaLogicDrawer.cs +488 -0
- package/Editor/MetaLogicDrawer.cs.meta +11 -0
- package/Editor/RhythmContextEditor.EditorDrawer.cs +46 -0
- package/Editor/RhythmContextEditor.EditorDrawer.cs.meta +3 -0
- package/Editor/RhythmContextEditor.cs +587 -0
- package/Editor/RhythmContextEditor.cs.meta +3 -0
- package/Editor/RhythmGameEditor.cs +45 -0
- package/Editor/RhythmGameEditor.cs.meta +11 -0
- package/Editor/RhythmTileEditor.cs +93 -0
- package/Editor/RhythmTileEditor.cs.meta +11 -0
- package/Editor/TagConfigDrawer.cs +30 -0
- package/Editor/TagConfigDrawer.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/LICENSE.md +7 -0
- package/LICENSE.md.meta +7 -0
- package/README.md +88 -0
- package/README.md.meta +7 -0
- package/Runtime/AssemblyInfo.cs +4 -0
- package/Runtime/AssemblyInfo.cs.meta +11 -0
- package/Runtime/Input/Base/BaseTileInput.cs +44 -0
- package/Runtime/Input/Base/BaseTileInput.cs.meta +11 -0
- package/Runtime/Input/Base/IInputHandler.cs +11 -0
- package/Runtime/Input/Base/IInputHandler.cs.meta +11 -0
- package/Runtime/Input/Base/InputData.cs +94 -0
- package/Runtime/Input/Base/InputData.cs.meta +3 -0
- package/Runtime/Input/Base/InputDirection.cs +17 -0
- package/Runtime/Input/Base/InputDirection.cs.meta +3 -0
- package/Runtime/Input/Base/InputPhase.cs +4 -0
- package/Runtime/Input/Base/InputPhase.cs.meta +3 -0
- package/Runtime/Input/Base.meta +3 -0
- package/Runtime/Input/Components/DragInput.cs +44 -0
- package/Runtime/Input/Components/DragInput.cs.meta +11 -0
- package/Runtime/Input/Components/HoldInput.cs +75 -0
- package/Runtime/Input/Components/HoldInput.cs.meta +12 -0
- package/Runtime/Input/Components/SwipeInput.cs +45 -0
- package/Runtime/Input/Components/SwipeInput.cs.meta +12 -0
- package/Runtime/Input/Components/TouchInput.cs +31 -0
- package/Runtime/Input/Components/TouchInput.cs.meta +11 -0
- package/Runtime/Input/Components.meta +8 -0
- package/Runtime/Input.meta +8 -0
- package/Runtime/MagicTilesCore.asmdef +24 -0
- package/Runtime/MagicTilesCore.asmdef.meta +7 -0
- package/Runtime/MoodChange/AdjustHue.ComponentInfo.cs +12 -0
- package/Runtime/MoodChange/AdjustHue.ComponentInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.MaterialInfo.cs +115 -0
- package/Runtime/MoodChange/AdjustHue.MaterialInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.ParticleSystemInfo.cs +36 -0
- package/Runtime/MoodChange/AdjustHue.ParticleSystemInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.SpriteRendererInfo.cs +28 -0
- package/Runtime/MoodChange/AdjustHue.SpriteRendererInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.TrailRendererInfo.cs +37 -0
- package/Runtime/MoodChange/AdjustHue.TrailRendererInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.cs +219 -0
- package/Runtime/MoodChange/AdjustHue.cs.meta +11 -0
- package/Runtime/MoodChange/ColorHueExtensions.cs +227 -0
- package/Runtime/MoodChange/ColorHueExtensions.cs.meta +3 -0
- package/Runtime/MoodChange/HueCache.cs +167 -0
- package/Runtime/MoodChange/HueCache.cs.meta +11 -0
- package/Runtime/MoodChange/MoodChange.cs +52 -0
- package/Runtime/MoodChange/MoodChange.cs.meta +3 -0
- package/Runtime/MoodChange.meta +3 -0
- package/Runtime/Physics/TriggerCallback.cs +21 -0
- package/Runtime/Physics/TriggerCallback.cs.meta +3 -0
- package/Runtime/Physics.meta +8 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.cs +153 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.cs.meta +11 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.prefab +145 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.prefab.meta +7 -0
- package/Runtime/Preset/AudioSourcePlayer.meta +8 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.cs +22 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.cs.meta +11 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.prefab +188 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.prefab.meta +7 -0
- package/Runtime/Preset/AudioTimeText.meta +8 -0
- package/Runtime/Preset/ParticleSystemPlayer/ParticleSystemPlayer.cs +32 -0
- package/Runtime/Preset/ParticleSystemPlayer/ParticleSystemPlayer.cs.meta +11 -0
- package/Runtime/Preset/ParticleSystemPlayer.meta +8 -0
- package/Runtime/Preset/RendererAlpha.cs +56 -0
- package/Runtime/Preset/RendererAlpha.cs.meta +11 -0
- package/Runtime/Preset/ScoreText/ScoreText.anim +198 -0
- package/Runtime/Preset/ScoreText/ScoreText.anim.meta +8 -0
- package/Runtime/Preset/ScoreText/ScoreText.cs +32 -0
- package/Runtime/Preset/ScoreText/ScoreText.cs.meta +11 -0
- package/Runtime/Preset/ScoreText/ScoreText_2D.prefab +170 -0
- package/Runtime/Preset/ScoreText/ScoreText_2D.prefab.meta +7 -0
- package/Runtime/Preset/ScoreText/ScoreText_3D.prefab +206 -0
- package/Runtime/Preset/ScoreText/ScoreText_3D.prefab.meta +7 -0
- package/Runtime/Preset/ScoreText.meta +8 -0
- package/Runtime/Preset/StartHint/StartHint.cs +26 -0
- package/Runtime/Preset/StartHint/StartHint.cs.meta +3 -0
- package/Runtime/Preset/StartHint.meta +8 -0
- package/Runtime/Preset/WowText/WowText.cs +38 -0
- package/Runtime/Preset/WowText/WowText.cs.meta +3 -0
- package/Runtime/Preset/WowText.meta +8 -0
- package/Runtime/Preset.meta +8 -0
- package/Runtime/Rhythm/Components/Controls.meta +8 -0
- package/Runtime/Rhythm/Components/Helper/CameraFollow.cs +28 -0
- package/Runtime/Rhythm/Components/Helper/CameraFollow.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper/MeshSpriteSorter.cs +89 -0
- package/Runtime/Rhythm/Components/Helper/MeshSpriteSorter.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper/RecycleLayoutZ.cs +74 -0
- package/Runtime/Rhythm/Components/Helper/RecycleLayoutZ.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper.meta +8 -0
- package/Runtime/Rhythm/Components.meta +8 -0
- package/Runtime/Rhythm/Core/GameMode.cs +10 -0
- package/Runtime/Rhythm/Core/GameMode.cs.meta +3 -0
- package/Runtime/Rhythm/Core/IAudioPlayer.cs +16 -0
- package/Runtime/Rhythm/Core/IAudioPlayer.cs.meta +3 -0
- package/Runtime/Rhythm/Core/IRhythmBehaviour.cs +10 -0
- package/Runtime/Rhythm/Core/IRhythmBehaviour.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmBehaviour.cs +57 -0
- package/Runtime/Rhythm/Core/RhythmBehaviour.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmDebug.cs +48 -0
- package/Runtime/Rhythm/Core/RhythmDebug.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmGameT.cs +323 -0
- package/Runtime/Rhythm/Core/RhythmGameT.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmMatch.cs +65 -0
- package/Runtime/Rhythm/Core/RhythmMatch.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmTile.cs +77 -0
- package/Runtime/Rhythm/Core/RhythmTile.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmTileHandler.cs +59 -0
- package/Runtime/Rhythm/Core/RhythmTileHandler.cs.meta +3 -0
- package/Runtime/Rhythm/Core.meta +8 -0
- package/Runtime/Rhythm/Extensions/CollectionExtensions.cs +120 -0
- package/Runtime/Rhythm/Extensions/CollectionExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/ColliderExtensions.cs +27 -0
- package/Runtime/Rhythm/Extensions/ColliderExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/GameHandlerExtensions.cs +56 -0
- package/Runtime/Rhythm/Extensions/GameHandlerExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/GameObjectExtensions.cs +61 -0
- package/Runtime/Rhythm/Extensions/GameObjectExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/InputDirectionExtensions.cs +76 -0
- package/Runtime/Rhythm/Extensions/InputDirectionExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/MTCListExtensions.cs +127 -0
- package/Runtime/Rhythm/Extensions/MTCListExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/MeshRendererExtensions.cs +81 -0
- package/Runtime/Rhythm/Extensions/MeshRendererExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/ParticleSystemExtensions.cs +54 -0
- package/Runtime/Rhythm/Extensions/ParticleSystemExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions.meta +8 -0
- package/Runtime/Rhythm/Game/MTCSongAutoStart.cs +40 -0
- package/Runtime/Rhythm/Game/MTCSongAutoStart.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmConfig.cs +68 -0
- package/Runtime/Rhythm/Game/RhythmConfig.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Api.cs +533 -0
- package/Runtime/Rhythm/Game/RhythmContext.Api.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Dev.cs +121 -0
- package/Runtime/Rhythm/Game/RhythmContext.Dev.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Initialization.cs +114 -0
- package/Runtime/Rhythm/Game/RhythmContext.Initialization.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Runtime.cs +126 -0
- package/Runtime/Rhythm/Game/RhythmContext.Runtime.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.State.cs +221 -0
- package/Runtime/Rhythm/Game/RhythmContext.State.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Tile.cs +90 -0
- package/Runtime/Rhythm/Game/RhythmContext.Tile.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.TimeMachine.cs +315 -0
- package/Runtime/Rhythm/Game/RhythmContext.TimeMachine.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.cs +312 -0
- package/Runtime/Rhythm/Game/RhythmContext.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContextExtensions.cs +91 -0
- package/Runtime/Rhythm/Game/RhythmContextExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Game/Tile/ITileProgress.cs +7 -0
- package/Runtime/Rhythm/Game/Tile/ITileProgress.cs.meta +3 -0
- package/Runtime/Rhythm/Game/Tile/TileContext.cs +194 -0
- package/Runtime/Rhythm/Game/Tile/TileContext.cs.meta +11 -0
- package/Runtime/Rhythm/Game/Tile.meta +3 -0
- package/Runtime/Rhythm/Game.meta +3 -0
- package/Runtime/Rhythm/Math/Parabol.cs +35 -0
- package/Runtime/Rhythm/Math/Parabol.cs.meta +11 -0
- package/Runtime/Rhythm/Math.meta +8 -0
- package/Runtime/Rhythm/System/Event/GameEvent.cs +82 -0
- package/Runtime/Rhythm/System/Event/GameEvent.cs.meta +3 -0
- package/Runtime/Rhythm/System/Event.meta +8 -0
- package/Runtime/Rhythm/System/Meta/MetaLogic.cs +121 -0
- package/Runtime/Rhythm/System/Meta/MetaLogic.cs.meta +11 -0
- package/Runtime/Rhythm/System/Meta/VisualSpeedMeta.cs +132 -0
- package/Runtime/Rhythm/System/Meta/VisualSpeedMeta.cs.meta +11 -0
- package/Runtime/Rhythm/System/Meta.meta +8 -0
- package/Runtime/Rhythm/System/SongData/ListSongNote.cs +45 -0
- package/Runtime/Rhythm/System/SongData/ListSongNote.cs.meta +3 -0
- package/Runtime/Rhythm/System/SongData.meta +8 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.State.cs +22 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.State.cs.meta +11 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.cs +138 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.cs.meta +11 -0
- package/Runtime/Rhythm/System/StateMachine.meta +8 -0
- package/Runtime/Rhythm/System/TimeKnot/ListTimeKnots.cs +135 -0
- package/Runtime/Rhythm/System/TimeKnot/ListTimeKnots.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeKnot.meta +8 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeInterpolator.cs +365 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeInterpolator.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeMarker.cs +107 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeMarker.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeNode.cs +14 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeNode.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeSpanNode.cs +21 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeSpanNode.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.ZLaneSpeed.cs +28 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.ZLaneSpeed.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.cs +131 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeMachine.meta +8 -0
- package/Runtime/Rhythm/System/VisualKnot/VisualKnotLogic.cs +160 -0
- package/Runtime/Rhythm/System/VisualKnot/VisualKnotLogic.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualKnot.meta +8 -0
- package/Runtime/Rhythm/System/VisualWarp/IVisualWarp.cs +10 -0
- package/Runtime/Rhythm/System/VisualWarp/IVisualWarp.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualWarp/LinearVisualWarp.cs +27 -0
- package/Runtime/Rhythm/System/VisualWarp/LinearVisualWarp.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualWarp.meta +8 -0
- package/Runtime/Rhythm/System.meta +8 -0
- package/Runtime/Rhythm.meta +8 -0
- package/Runtime.meta +8 -0
- package/package.json +12 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
# Input System Guide
|
|
2
|
+
|
|
3
|
+
## 🎯 System Overview
|
|
4
|
+
|
|
5
|
+
The RhythmEngine Input System provides **unified input handling** for rhythm game tiles with support for touch, hold, and swipe gestures. It features automatic input handler detection, world position calculation, and direction-based gesture recognition.
|
|
6
|
+
|
|
7
|
+
## 🏗️ Core Architecture
|
|
8
|
+
|
|
9
|
+
### Input Data Structure
|
|
10
|
+
```csharp
|
|
11
|
+
public readonly struct InputData
|
|
12
|
+
{
|
|
13
|
+
public readonly InputPhase phase; // Start, Progress, End, Miss
|
|
14
|
+
public readonly Vector3 worldPosition; // 3D world coordinates
|
|
15
|
+
public readonly Vector3 deltaPosition; // Movement delta
|
|
16
|
+
public readonly byte direction; // 8-directional (0-7)
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Input Phases
|
|
21
|
+
```csharp
|
|
22
|
+
public enum InputPhase : byte
|
|
23
|
+
{
|
|
24
|
+
None, // No input
|
|
25
|
+
Start, // Input began (touch down)
|
|
26
|
+
Progress, // Input continuing (drag/hold)
|
|
27
|
+
End, // Input finished (touch up)
|
|
28
|
+
Miss // Input validation failed
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🎮 Input Components
|
|
33
|
+
|
|
34
|
+
### BaseTileInput (Abstract Base)
|
|
35
|
+
```csharp
|
|
36
|
+
public abstract class BaseTileInput : MonoBehaviour
|
|
37
|
+
```
|
|
38
|
+
**Features:**
|
|
39
|
+
- **Automatic handler detection** - Finds `IInputHandler` components
|
|
40
|
+
- **Collider validation** - Ensures input hits correct target
|
|
41
|
+
- **World position calculation** - Converts screen to 3D coordinates
|
|
42
|
+
- **Performance optimized** - Aggressive inlining for hot paths
|
|
43
|
+
|
|
44
|
+
**Key Methods:**
|
|
45
|
+
```csharp
|
|
46
|
+
protected bool ValidateInput(PointerEventData eventData) // Collision validation
|
|
47
|
+
protected Vector3 GetWorldPos(PointerEventData eventData) // Screen to world conversion
|
|
48
|
+
public void SetTargetCollider(Collider collider) // Runtime collider assignment
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### TouchInput (Instant Tap)
|
|
52
|
+
```csharp
|
|
53
|
+
public sealed class TouchInput : BaseTileInput, IPointerDownHandler
|
|
54
|
+
```
|
|
55
|
+
**Usage:** Short tiles, instant actions, tap-to-hit mechanics
|
|
56
|
+
|
|
57
|
+
**Behavior:**
|
|
58
|
+
- Triggers on `OnPointerDown` only
|
|
59
|
+
- Calls both `OnInputBegin` and `OnInputEnd` immediately
|
|
60
|
+
- Perfect for short tiles that don't require hold duration
|
|
61
|
+
|
|
62
|
+
**Example:**
|
|
63
|
+
```csharp
|
|
64
|
+
public class ShortTile : MonoBehaviour, IInputHandler
|
|
65
|
+
{
|
|
66
|
+
public void OnInputBegin(InputData inputData)
|
|
67
|
+
{
|
|
68
|
+
// Handle tap start
|
|
69
|
+
Debug.Log($"Tile tapped at {inputData.worldPosition}");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public void OnInputUpdate(InputData inputData) { /* Not called for TouchInput */ }
|
|
73
|
+
|
|
74
|
+
public void OnInputEnd(InputData inputData)
|
|
75
|
+
{
|
|
76
|
+
// Handle tap completion
|
|
77
|
+
MarkTileComplete();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### HoldInput (Continuous Press)
|
|
83
|
+
```csharp
|
|
84
|
+
public sealed class HoldInput : BaseTileInput, IPointerDownHandler, IPointerUpHandler, IPointerMoveHandler
|
|
85
|
+
```
|
|
86
|
+
**Usage:** Long tiles, hold mechanics, progress tracking
|
|
87
|
+
|
|
88
|
+
**Behavior:**
|
|
89
|
+
- `OnPointerDown` → `OnInputBegin` + starts hold coroutine
|
|
90
|
+
- Continuous `OnInputUpdate` calls during hold
|
|
91
|
+
- `OnPointerMove` → Updates world position
|
|
92
|
+
- `OnPointerUp` → `OnInputEnd` + stops hold coroutine
|
|
93
|
+
|
|
94
|
+
**Features:**
|
|
95
|
+
- **Pointer ID tracking** - Handles multi-touch correctly
|
|
96
|
+
- **World position updates** - Tracks finger movement in 3D space
|
|
97
|
+
- **Hold validation** - Prevents multiple simultaneous holds
|
|
98
|
+
- **Debug visualization** - Optional world position visualizer
|
|
99
|
+
|
|
100
|
+
**Example:**
|
|
101
|
+
```csharp
|
|
102
|
+
public class LongTile : MonoBehaviour, IInputHandler, ITileProgress
|
|
103
|
+
{
|
|
104
|
+
private float holdStartTime;
|
|
105
|
+
private bool isHolding;
|
|
106
|
+
|
|
107
|
+
public void OnInputBegin(InputData inputData)
|
|
108
|
+
{
|
|
109
|
+
holdStartTime = Time.time;
|
|
110
|
+
isHolding = true;
|
|
111
|
+
Debug.Log("Hold started");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public void OnInputUpdate(InputData inputData)
|
|
115
|
+
{
|
|
116
|
+
if (!isHolding) return;
|
|
117
|
+
|
|
118
|
+
float holdDuration = Time.time - holdStartTime;
|
|
119
|
+
float progress = holdDuration / requiredHoldTime;
|
|
120
|
+
UpdateProgress(Mathf.Clamp01(progress));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public void OnInputEnd(InputData inputData)
|
|
124
|
+
{
|
|
125
|
+
isHolding = false;
|
|
126
|
+
Debug.Log("Hold ended");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### SwipeInput (Directional Gestures)
|
|
132
|
+
```csharp
|
|
133
|
+
public sealed class SwipeInput : BaseTileInput, IPointerDownHandler, IPointerUpHandler, IPointerMoveHandler
|
|
134
|
+
```
|
|
135
|
+
**Usage:** Swipe tiles, directional mechanics, gesture recognition
|
|
136
|
+
|
|
137
|
+
**Behavior:**
|
|
138
|
+
- Tracks swipe direction using `DirectionUtil`
|
|
139
|
+
- Calculates delta movement and direction
|
|
140
|
+
- Validates minimum swipe distance
|
|
141
|
+
- Supports 8-directional recognition (N, NE, E, SE, S, SW, W, NW)
|
|
142
|
+
|
|
143
|
+
**Configuration:**
|
|
144
|
+
```csharp
|
|
145
|
+
[SerializeField] private float minSwipeDistance = 0.5f; // Minimum distance for valid swipe
|
|
146
|
+
[SerializeField] private float swipeTimeLimit = 2f; // Maximum time for swipe completion
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Example:**
|
|
150
|
+
```csharp
|
|
151
|
+
public class SwipeTile : MonoBehaviour, IInputHandler
|
|
152
|
+
{
|
|
153
|
+
[SerializeField] private SwipeDirection requiredDirection;
|
|
154
|
+
|
|
155
|
+
public void OnInputBegin(InputData inputData)
|
|
156
|
+
{
|
|
157
|
+
// Swipe started
|
|
158
|
+
ShowSwipeIndicator();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
public void OnInputUpdate(InputData inputData)
|
|
162
|
+
{
|
|
163
|
+
// Track swipe progress
|
|
164
|
+
if (inputData.HasDelta())
|
|
165
|
+
{
|
|
166
|
+
UpdateSwipeVisualization(inputData.deltaPosition);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public void OnInputEnd(InputData inputData)
|
|
171
|
+
{
|
|
172
|
+
// Validate swipe direction
|
|
173
|
+
if (inputData.IsValidDirection())
|
|
174
|
+
{
|
|
175
|
+
var swipedDirection = (SwipeDirection)inputData.direction;
|
|
176
|
+
if (swipedDirection == requiredDirection)
|
|
177
|
+
{
|
|
178
|
+
CompleteSwipe();
|
|
179
|
+
}
|
|
180
|
+
else
|
|
181
|
+
{
|
|
182
|
+
FailSwipe();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## 🧭 Direction System
|
|
190
|
+
|
|
191
|
+
### DirectionUtil (8-Directional Recognition)
|
|
192
|
+
```csharp
|
|
193
|
+
public static class DirectionUtil
|
|
194
|
+
```
|
|
195
|
+
**Features:**
|
|
196
|
+
- **8-direction mapping** - N(0), NE(1), E(2), SE(3), S(4), SW(5), W(6), NW(7)
|
|
197
|
+
- **Angle-based calculation** - Converts Vector3 delta to direction byte
|
|
198
|
+
- **Name mapping** - Human-readable direction names
|
|
199
|
+
|
|
200
|
+
**Usage:**
|
|
201
|
+
```csharp
|
|
202
|
+
Vector3 swipeDelta = endPos - startPos;
|
|
203
|
+
byte direction = DirectionUtil.GetDirection(swipeDelta);
|
|
204
|
+
string dirName = DirectionUtil.GetDirectionName(direction);
|
|
205
|
+
|
|
206
|
+
// Example: swipeDelta = (1, 0, 1) → direction = 1 (NE) → dirName = "NorthEast"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Direction Mapping:**
|
|
210
|
+
```
|
|
211
|
+
N(0)
|
|
212
|
+
NW(7) ↑ NE(1)
|
|
213
|
+
W(6)← + →E(2)
|
|
214
|
+
SW(5) ↓ SE(3)
|
|
215
|
+
S(4)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## 🔌 Integration Patterns
|
|
219
|
+
|
|
220
|
+
### IInputHandler Interface
|
|
221
|
+
```csharp
|
|
222
|
+
public interface IInputHandler
|
|
223
|
+
{
|
|
224
|
+
void OnInputBegin(InputData inputData); // Input started
|
|
225
|
+
void OnInputUpdate(InputData inputData); // Input progressing (hold/swipe only)
|
|
226
|
+
void OnInputEnd(InputData inputData); // Input completed
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Automatic Handler Detection
|
|
231
|
+
```csharp
|
|
232
|
+
// BaseTileInput automatically finds IInputHandler on the same GameObject
|
|
233
|
+
private void FindInputHandler()
|
|
234
|
+
{
|
|
235
|
+
var handlers = GetComponents<MonoBehaviour>();
|
|
236
|
+
for (int i = 0; i < handlers.Length; i++)
|
|
237
|
+
{
|
|
238
|
+
if (handlers[i] is IInputHandler)
|
|
239
|
+
{
|
|
240
|
+
handler = handlers[i];
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### Manual Handler Assignment
|
|
248
|
+
```csharp
|
|
249
|
+
// Override automatic detection
|
|
250
|
+
touchInput.handler = customInputHandler;
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## 🎵 Rhythm Game Integration
|
|
254
|
+
|
|
255
|
+
### Tile Setup Pattern
|
|
256
|
+
```csharp
|
|
257
|
+
public class MyTile : RhythmTile, IInputHandler
|
|
258
|
+
{
|
|
259
|
+
[SerializeField] private TouchInput touchInput;
|
|
260
|
+
[SerializeField] private HoldInput holdInput;
|
|
261
|
+
[SerializeField] private SwipeInput swipeInput;
|
|
262
|
+
|
|
263
|
+
public void OnAttach(TileContext tile)
|
|
264
|
+
{
|
|
265
|
+
// Configure input based on tile type
|
|
266
|
+
switch (tile.note.type)
|
|
267
|
+
{
|
|
268
|
+
case "short":
|
|
269
|
+
touchInput.enabled = true;
|
|
270
|
+
holdInput.enabled = false;
|
|
271
|
+
swipeInput.enabled = false;
|
|
272
|
+
break;
|
|
273
|
+
|
|
274
|
+
case "long":
|
|
275
|
+
touchInput.enabled = false;
|
|
276
|
+
holdInput.enabled = true;
|
|
277
|
+
swipeInput.enabled = false;
|
|
278
|
+
break;
|
|
279
|
+
|
|
280
|
+
case "swipe":
|
|
281
|
+
touchInput.enabled = false;
|
|
282
|
+
holdInput.enabled = false;
|
|
283
|
+
swipeInput.enabled = true;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Set target collider for all inputs
|
|
288
|
+
var collider = GetComponent<Collider>();
|
|
289
|
+
touchInput.SetTargetCollider(collider);
|
|
290
|
+
holdInput.SetTargetCollider(collider);
|
|
291
|
+
swipeInput.SetTargetCollider(collider);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
public void OnInputBegin(InputData inputData)
|
|
295
|
+
{
|
|
296
|
+
// Unified input handling
|
|
297
|
+
context.BeginTileTouch(tileContext.index);
|
|
298
|
+
|
|
299
|
+
// Log input for debugging
|
|
300
|
+
RhythmContext.LogInput($"Tile {tileContext.index} input began at {inputData.worldPosition}");
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
public void OnInputUpdate(InputData inputData)
|
|
304
|
+
{
|
|
305
|
+
// Handle continuous input (hold/swipe)
|
|
306
|
+
if (tileContext.Status == TileStatus.Touching)
|
|
307
|
+
{
|
|
308
|
+
UpdateTileProgress(inputData);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
public void OnInputEnd(InputData inputData)
|
|
313
|
+
{
|
|
314
|
+
// Complete tile interaction
|
|
315
|
+
if (tileContext.Status == TileStatus.Touching)
|
|
316
|
+
{
|
|
317
|
+
context.EndTileTouch(tileContext.index);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Multi-Input Tiles
|
|
324
|
+
```csharp
|
|
325
|
+
public class HybridTile : MonoBehaviour, IInputHandler
|
|
326
|
+
{
|
|
327
|
+
[SerializeField] private TouchInput quickTap;
|
|
328
|
+
[SerializeField] private HoldInput longHold;
|
|
329
|
+
|
|
330
|
+
private float inputStartTime;
|
|
331
|
+
private bool isQuickTap;
|
|
332
|
+
|
|
333
|
+
public void OnInputBegin(InputData inputData)
|
|
334
|
+
{
|
|
335
|
+
inputStartTime = Time.time;
|
|
336
|
+
isQuickTap = false;
|
|
337
|
+
|
|
338
|
+
// Start timer to determine input type
|
|
339
|
+
StartCoroutine(DetermineInputType());
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
public void OnInputUpdate(InputData inputData)
|
|
343
|
+
{
|
|
344
|
+
// This is definitely a hold
|
|
345
|
+
isQuickTap = false;
|
|
346
|
+
HandleHoldProgress(inputData);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
public void OnInputEnd(InputData inputData)
|
|
350
|
+
{
|
|
351
|
+
float inputDuration = Time.time - inputStartTime;
|
|
352
|
+
|
|
353
|
+
if (inputDuration < 0.2f && isQuickTap)
|
|
354
|
+
{
|
|
355
|
+
HandleQuickTap();
|
|
356
|
+
}
|
|
357
|
+
else
|
|
358
|
+
{
|
|
359
|
+
HandleHoldComplete();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
private IEnumerator DetermineInputType()
|
|
364
|
+
{
|
|
365
|
+
yield return new WaitForSeconds(0.1f);
|
|
366
|
+
isQuickTap = true; // If we reach here without OnInputUpdate, it's a quick tap
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
## 🚀 Performance Optimization
|
|
372
|
+
|
|
373
|
+
### Aggressive Inlining
|
|
374
|
+
```csharp
|
|
375
|
+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
376
|
+
protected bool ValidateInput(PointerEventData eventData)
|
|
377
|
+
{
|
|
378
|
+
var hitGO = eventData?.pointerEnter?.gameObject;
|
|
379
|
+
if (hitGO == null) return false;
|
|
380
|
+
return hitGO == targetCollider.gameObject || hitGO == gameObject;
|
|
381
|
+
}
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
### Efficient Direction Calculation
|
|
385
|
+
```csharp
|
|
386
|
+
// DirectionUtil uses optimized angle calculation
|
|
387
|
+
public static byte GetDirection(Vector3 delta)
|
|
388
|
+
{
|
|
389
|
+
if (delta.sqrMagnitude < 0.001f) return 255; // Invalid
|
|
390
|
+
|
|
391
|
+
float angle = Mathf.Atan2(delta.z, delta.x) * Mathf.Rad2Deg;
|
|
392
|
+
if (angle < 0) angle += 360f;
|
|
393
|
+
|
|
394
|
+
return (byte)Mathf.RoundToInt(angle / 45f) % 8;
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Memory-Efficient InputData
|
|
399
|
+
```csharp
|
|
400
|
+
// InputData is a readonly struct - no heap allocations
|
|
401
|
+
public readonly struct InputData
|
|
402
|
+
{
|
|
403
|
+
// All fields are readonly and value types
|
|
404
|
+
// Passed by value, no GC pressure
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## 🎯 Key Benefits
|
|
409
|
+
|
|
410
|
+
1. **Unified Interface**: Single `IInputHandler` for all input types
|
|
411
|
+
2. **Automatic Detection**: No manual wiring required
|
|
412
|
+
3. **Performance Optimized**: Aggressive inlining and struct-based data
|
|
413
|
+
4. **Multi-Touch Safe**: Proper pointer ID tracking
|
|
414
|
+
5. **Direction Aware**: Built-in 8-directional gesture recognition
|
|
415
|
+
6. **Rhythm Game Ready**: Designed for tile-based gameplay
|
|
416
|
+
7. **Extensible**: Easy to add new input types
|
|
417
|
+
8. **Debug Friendly**: Built-in logging and visualization support
|
|
418
|
+
|
|
419
|
+
The Input System provides a **solid foundation** for rhythm game interactions while maintaining **high performance** and **ease of use**.
|