├── .gitignore ├── Assets ├── naichilab.meta └── naichilab │ ├── TouchManager.meta │ └── TouchManager │ ├── Prefabs.meta │ ├── Prefabs │ ├── TouchManager.prefab │ └── TouchManager.prefab.meta │ ├── Sample.meta │ ├── Sample │ ├── Circle.cs │ ├── Circle.cs.meta │ ├── Circle.png │ ├── Circle.png.meta │ ├── Image.prefab │ ├── Image.prefab.meta │ ├── Sample.unity │ ├── Sample.unity.meta │ ├── TouchListener.prefab │ ├── TouchListener.prefab.meta │ ├── TouchListenerSample.cs │ └── TouchListenerSample.cs.meta │ ├── Scripts.meta │ └── Scripts │ ├── CustomInput.cs │ ├── CustomInput.cs.meta │ ├── DetectGestures.meta │ ├── DetectGestures │ ├── DragDetector.cs │ ├── DragDetector.cs.meta │ ├── FlickDetector.cs │ ├── FlickDetector.cs.meta │ ├── IGestureDetector.cs │ ├── IGestureDetector.cs.meta │ ├── TouchDetector.cs │ └── TouchDetector.cs.meta │ ├── Events.meta │ ├── Events │ ├── CustomInputEventArgs.cs │ ├── CustomInputEventArgs.cs.meta │ ├── FlickEventArgs.cs │ └── FlickEventArgs.cs.meta │ ├── TouchManager.cs │ └── TouchManager.cs.meta ├── LICENSE ├── ProjectSettings └── ProjectVersion.txt ├── README.md └── TouchManager.unitypackage /.gitignore: -------------------------------------------------------------------------------- 1 | # ---------------[ Unity generated ]------------------ # 2 | [Ll]ibrary/ 3 | [Tt]emp/ 4 | [Oo]bj/ 5 | UnityGenerated/ 6 | ProjectSettings/*.asset 7 | 8 | # ----[ Visual Studio / MonoDevelop generated ]------- # 9 | 10 | ExportedObj/ 11 | *.svd 12 | *.userprefs 13 | *.csproj 14 | *.pidb 15 | *.suo 16 | *.sln 17 | *.user 18 | *.unityproj 19 | *.booproj 20 | 21 | # -------------[ OS generated ]------------------------ # 22 | .DS_Store 23 | .DS_Store? 24 | ._* 25 | .Spotlight-V100 26 | .Trashes 27 | Icon? 28 | ehthumbs.db 29 | Thumbs.db 30 | 31 | # -------------[ Build ]------------------------ # 32 | *.html 33 | *.unity3d 34 | 35 | # -------------[ Release ]------------------------ # 36 | iOSRelease/ 37 | *.keystore 38 | *.apk -------------------------------------------------------------------------------- /Assets/naichilab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d090d9e4866940128917785740b7b71 3 | folderAsset: yes 4 | timeCreated: 1427026266 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21846da62abe6424c9b2b764b2ee6619 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Prefabs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d2a1cb656bdb547abbf8b3a177b68150 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Prefabs/TouchManager.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &147012 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 447012} 11 | - 114: {fileID: 11448810} 12 | - 114: {fileID: 11448804} 13 | - 114: {fileID: 11448806} 14 | - 114: {fileID: 11448808} 15 | m_Layer: 0 16 | m_Name: TouchManager 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &447012 23 | Transform: 24 | m_ObjectHideFlags: 1 25 | m_PrefabParentObject: {fileID: 0} 26 | m_PrefabInternal: {fileID: 100100000} 27 | m_GameObject: {fileID: 147012} 28 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 1, y: 1, z: 1} 31 | m_Children: [] 32 | m_Father: {fileID: 0} 33 | m_RootOrder: 0 34 | --- !u!114 &11448804 35 | MonoBehaviour: 36 | m_ObjectHideFlags: 1 37 | m_PrefabParentObject: {fileID: 0} 38 | m_PrefabInternal: {fileID: 100100000} 39 | m_GameObject: {fileID: 147012} 40 | m_Enabled: 1 41 | m_EditorHideFlags: 0 42 | m_Script: {fileID: 11500000, guid: 0e479e77d3d5147bcbdb68359450bf5c, type: 3} 43 | m_Name: 44 | m_EditorClassIdentifier: 45 | Enabled: 1 46 | LevelingFrameCount: 3 47 | DetectAcceleration: 10000 48 | DefeatSpeed: 100 49 | MinFlickDistance: 0 50 | --- !u!114 &11448806 51 | MonoBehaviour: 52 | m_ObjectHideFlags: 1 53 | m_PrefabParentObject: {fileID: 0} 54 | m_PrefabInternal: {fileID: 100100000} 55 | m_GameObject: {fileID: 147012} 56 | m_Enabled: 1 57 | m_EditorHideFlags: 0 58 | m_Script: {fileID: 11500000, guid: 62c6e9ff53c6c4922bd569b903e3179c, type: 3} 59 | m_Name: 60 | m_EditorClassIdentifier: 61 | --- !u!114 &11448808 62 | MonoBehaviour: 63 | m_ObjectHideFlags: 1 64 | m_PrefabParentObject: {fileID: 0} 65 | m_PrefabInternal: {fileID: 100100000} 66 | m_GameObject: {fileID: 147012} 67 | m_Enabled: 1 68 | m_EditorHideFlags: 0 69 | m_Script: {fileID: 11500000, guid: 7eba50494cb2a4696a818eedaa9abfa8, type: 3} 70 | m_Name: 71 | m_EditorClassIdentifier: 72 | --- !u!114 &11448810 73 | MonoBehaviour: 74 | m_ObjectHideFlags: 1 75 | m_PrefabParentObject: {fileID: 0} 76 | m_PrefabInternal: {fileID: 100100000} 77 | m_GameObject: {fileID: 147012} 78 | m_Enabled: 1 79 | m_EditorHideFlags: 0 80 | m_Script: {fileID: 11500000, guid: 6c36263aaa51f44299222467462737cb, type: 3} 81 | m_Name: 82 | m_EditorClassIdentifier: 83 | DebugMode: 1 84 | --- !u!1001 &100100000 85 | Prefab: 86 | m_ObjectHideFlags: 1 87 | serializedVersion: 2 88 | m_Modification: 89 | m_TransformParent: {fileID: 0} 90 | m_Modifications: [] 91 | m_RemovedComponents: [] 92 | m_ParentPrefab: {fileID: 0} 93 | m_RootGameObject: {fileID: 147012} 94 | m_IsPrefabParent: 1 95 | m_IsExploded: 1 96 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Prefabs/TouchManager.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b54aee326cf1b4bb180be1281c49861b 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7887dc469828d450faef0ea6a5ad2286 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/Circle.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Circle : MonoBehaviour 5 | { 6 | public Vector3 Speed; 7 | // Use this for initialization 8 | void Start () 9 | { 10 | 11 | } 12 | // Update is called once per frame 13 | void Update () 14 | { 15 | var offset = new Vector3 (this.Speed.x * Time.deltaTime, this.Speed.y * Time.deltaTime, 0); 16 | this.MovePosition (offset); 17 | } 18 | 19 | public void SetPosition (Vector3 pos) 20 | { 21 | this.transform.position = pos; 22 | } 23 | 24 | public void MovePosition (Vector3 offset) 25 | { 26 | var p = this.transform.position; 27 | this.transform.position = new Vector3 (p.x + offset.x, p.y + offset.y, p.z); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/Circle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21b82da446c3542c09aa9b7ccc2f2ad7 3 | timeCreated: 1425713264 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/Circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naichilab/Unity-TouchManager/f3cb05f044a44807faae76ca2c6345458ce73f19/Assets/naichilab/TouchManager/Sample/Circle.png -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/Circle.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2fbcb9fd677349649ffa88bcec48ed3 3 | timeCreated: 1425712545 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: .25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 8 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | spriteMode: 1 41 | spriteExtrude: 1 42 | spriteMeshType: 1 43 | alignment: 0 44 | spritePivot: {x: .5, y: .5} 45 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 46 | spritePixelsToUnits: 100 47 | alphaIsTransparency: 1 48 | textureType: 8 49 | buildTargetSettings: [] 50 | spriteSheet: 51 | sprites: [] 52 | spritePackingTag: 53 | userData: 54 | assetBundleName: 55 | assetBundleVariant: 56 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/Image.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &167388 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 224: {fileID: 22406206} 11 | - 222: {fileID: 22260040} 12 | - 114: {fileID: 11448062} 13 | - 114: {fileID: 11443752} 14 | m_Layer: 5 15 | m_Name: Image 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!114 &11443752 22 | MonoBehaviour: 23 | m_ObjectHideFlags: 1 24 | m_PrefabParentObject: {fileID: 0} 25 | m_PrefabInternal: {fileID: 100100000} 26 | m_GameObject: {fileID: 167388} 27 | m_Enabled: 1 28 | m_EditorHideFlags: 0 29 | m_Script: {fileID: 11500000, guid: 21b82da446c3542c09aa9b7ccc2f2ad7, type: 3} 30 | m_Name: 31 | m_EditorClassIdentifier: 32 | Speed: {x: 0, y: 0, z: 0} 33 | --- !u!114 &11448062 34 | MonoBehaviour: 35 | m_ObjectHideFlags: 1 36 | m_PrefabParentObject: {fileID: 0} 37 | m_PrefabInternal: {fileID: 100100000} 38 | m_GameObject: {fileID: 167388} 39 | m_Enabled: 1 40 | m_EditorHideFlags: 0 41 | m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} 42 | m_Name: 43 | m_EditorClassIdentifier: 44 | m_Material: {fileID: 0} 45 | m_Color: {r: 1, g: 1, b: 1, a: 1} 46 | m_Sprite: {fileID: 21300000, guid: b2fbcb9fd677349649ffa88bcec48ed3, type: 3} 47 | m_Type: 0 48 | m_PreserveAspect: 0 49 | m_FillCenter: 1 50 | m_FillMethod: 4 51 | m_FillAmount: 1 52 | m_FillClockwise: 1 53 | m_FillOrigin: 0 54 | --- !u!222 &22260040 55 | CanvasRenderer: 56 | m_ObjectHideFlags: 1 57 | m_PrefabParentObject: {fileID: 0} 58 | m_PrefabInternal: {fileID: 100100000} 59 | m_GameObject: {fileID: 167388} 60 | --- !u!224 &22406206 61 | RectTransform: 62 | m_ObjectHideFlags: 1 63 | m_PrefabParentObject: {fileID: 0} 64 | m_PrefabInternal: {fileID: 100100000} 65 | m_GameObject: {fileID: 167388} 66 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 67 | m_LocalPosition: {x: 0, y: 0, z: 0} 68 | m_LocalScale: {x: 1, y: 1, z: 1} 69 | m_Children: [] 70 | m_Father: {fileID: 0} 71 | m_RootOrder: 0 72 | m_AnchorMin: {x: .5, y: .5} 73 | m_AnchorMax: {x: .5, y: .5} 74 | m_AnchoredPosition: {x: 0, y: 0} 75 | m_SizeDelta: {x: 100, y: 100} 76 | m_Pivot: {x: .5, y: .5} 77 | --- !u!1001 &100100000 78 | Prefab: 79 | m_ObjectHideFlags: 1 80 | serializedVersion: 2 81 | m_Modification: 82 | m_TransformParent: {fileID: 0} 83 | m_Modifications: [] 84 | m_RemovedComponents: [] 85 | m_ParentPrefab: {fileID: 0} 86 | m_RootGameObject: {fileID: 167388} 87 | m_IsPrefabParent: 1 88 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/Image.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b97255ee88c6e4dd58f26fc61c64d668 3 | timeCreated: 1425713288 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/Sample.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | SceneSettings: 5 | m_ObjectHideFlags: 0 6 | m_PVSData: 7 | m_PVSObjectsArray: [] 8 | m_PVSPortalsArray: [] 9 | m_OcclusionBakeSettings: 10 | smallestOccluder: 5 11 | smallestHole: .25 12 | backfaceThreshold: 100 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 6 17 | m_Fog: 0 18 | m_FogColor: {r: .5, g: .5, b: .5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: .00999999978 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} 24 | m_AmbientEquatorColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} 25 | m_AmbientGroundColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 3 28 | m_SkyboxMaterial: {fileID: 0} 29 | m_HaloStrength: .5 30 | m_FlareStrength: 1 31 | m_FlareFadeSpeed: 3 32 | m_HaloTexture: {fileID: 0} 33 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 34 | m_DefaultReflectionMode: 0 35 | m_DefaultReflectionResolution: 128 36 | m_ReflectionBounces: 1 37 | m_ReflectionIntensity: 1 38 | m_CustomReflection: {fileID: 0} 39 | m_Sun: {fileID: 0} 40 | --- !u!127 &3 41 | LevelGameManager: 42 | m_ObjectHideFlags: 0 43 | --- !u!157 &4 44 | LightmapSettings: 45 | m_ObjectHideFlags: 0 46 | serializedVersion: 5 47 | m_GIWorkflowMode: 1 48 | m_LightmapsMode: 1 49 | m_GISettings: 50 | serializedVersion: 2 51 | m_BounceScale: 1 52 | m_IndirectOutputScale: 1 53 | m_AlbedoBoost: 1 54 | m_TemporalCoherenceThreshold: 1 55 | m_EnvironmentLightingMode: 0 56 | m_EnableBakedLightmaps: 1 57 | m_EnableRealtimeLightmaps: 0 58 | m_LightmapEditorSettings: 59 | serializedVersion: 3 60 | m_Resolution: 1 61 | m_BakeResolution: 50 62 | m_TextureWidth: 1024 63 | m_TextureHeight: 1024 64 | m_AOMaxDistance: 1 65 | m_Padding: 2 66 | m_CompAOExponent: 0 67 | m_LightmapParameters: {fileID: 0} 68 | m_TextureCompression: 0 69 | m_FinalGather: 0 70 | m_FinalGatherRayCount: 1024 71 | m_LightmapSnapshot: {fileID: 0} 72 | m_RuntimeCPUUsage: 25 73 | --- !u!196 &5 74 | NavMeshSettings: 75 | serializedVersion: 2 76 | m_ObjectHideFlags: 0 77 | m_BuildSettings: 78 | serializedVersion: 2 79 | agentRadius: .5 80 | agentHeight: 2 81 | agentSlope: 45 82 | agentClimb: .400000006 83 | ledgeDropHeight: 0 84 | maxJumpAcrossDistance: 0 85 | accuratePlacement: 0 86 | minRegionArea: 2 87 | cellSize: .166666657 88 | manualCellSize: 0 89 | m_NavMeshData: {fileID: 0} 90 | --- !u!1 &170752271 91 | GameObject: 92 | m_ObjectHideFlags: 0 93 | m_PrefabParentObject: {fileID: 0} 94 | m_PrefabInternal: {fileID: 0} 95 | serializedVersion: 4 96 | m_Component: 97 | - 224: {fileID: 170752275} 98 | - 223: {fileID: 170752274} 99 | - 114: {fileID: 170752273} 100 | - 114: {fileID: 170752272} 101 | m_Layer: 5 102 | m_Name: Canvas 103 | m_TagString: Untagged 104 | m_Icon: {fileID: 0} 105 | m_NavMeshLayer: 0 106 | m_StaticEditorFlags: 0 107 | m_IsActive: 1 108 | --- !u!114 &170752272 109 | MonoBehaviour: 110 | m_ObjectHideFlags: 0 111 | m_PrefabParentObject: {fileID: 0} 112 | m_PrefabInternal: {fileID: 0} 113 | m_GameObject: {fileID: 170752271} 114 | m_Enabled: 1 115 | m_EditorHideFlags: 0 116 | m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} 117 | m_Name: 118 | m_EditorClassIdentifier: 119 | m_IgnoreReversedGraphics: 1 120 | m_BlockingObjects: 0 121 | m_BlockingMask: 122 | serializedVersion: 2 123 | m_Bits: 4294967295 124 | --- !u!114 &170752273 125 | MonoBehaviour: 126 | m_ObjectHideFlags: 0 127 | m_PrefabParentObject: {fileID: 0} 128 | m_PrefabInternal: {fileID: 0} 129 | m_GameObject: {fileID: 170752271} 130 | m_Enabled: 1 131 | m_EditorHideFlags: 0 132 | m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} 133 | m_Name: 134 | m_EditorClassIdentifier: 135 | m_UiScaleMode: 0 136 | m_ReferencePixelsPerUnit: 100 137 | m_ScaleFactor: 1 138 | m_ReferenceResolution: {x: 800, y: 600} 139 | m_ScreenMatchMode: 0 140 | m_MatchWidthOrHeight: 0 141 | m_PhysicalUnit: 3 142 | m_FallbackScreenDPI: 96 143 | m_DefaultSpriteDPI: 96 144 | m_DynamicPixelsPerUnit: 1 145 | --- !u!223 &170752274 146 | Canvas: 147 | m_ObjectHideFlags: 0 148 | m_PrefabParentObject: {fileID: 0} 149 | m_PrefabInternal: {fileID: 0} 150 | m_GameObject: {fileID: 170752271} 151 | m_Enabled: 1 152 | serializedVersion: 2 153 | m_RenderMode: 0 154 | m_Camera: {fileID: 0} 155 | m_PlaneDistance: 100 156 | m_PixelPerfect: 0 157 | m_ReceivesEvents: 1 158 | m_OverrideSorting: 0 159 | m_OverridePixelPerfect: 0 160 | m_SortingLayerID: 0 161 | m_SortingOrder: 0 162 | --- !u!224 &170752275 163 | RectTransform: 164 | m_ObjectHideFlags: 0 165 | m_PrefabParentObject: {fileID: 0} 166 | m_PrefabInternal: {fileID: 0} 167 | m_GameObject: {fileID: 170752271} 168 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 169 | m_LocalPosition: {x: 0, y: 0, z: 0} 170 | m_LocalScale: {x: 0, y: 0, z: 0} 171 | m_Children: 172 | - {fileID: 1383673615} 173 | m_Father: {fileID: 0} 174 | m_RootOrder: 4 175 | m_AnchorMin: {x: 0, y: 0} 176 | m_AnchorMax: {x: 0, y: 0} 177 | m_AnchoredPosition: {x: 0, y: 0} 178 | m_SizeDelta: {x: 0, y: 0} 179 | m_Pivot: {x: 0, y: 0} 180 | --- !u!1 &658646008 181 | GameObject: 182 | m_ObjectHideFlags: 0 183 | m_PrefabParentObject: {fileID: 0} 184 | m_PrefabInternal: {fileID: 0} 185 | serializedVersion: 4 186 | m_Component: 187 | - 4: {fileID: 658646013} 188 | - 20: {fileID: 658646012} 189 | - 92: {fileID: 658646011} 190 | - 124: {fileID: 658646010} 191 | - 81: {fileID: 658646009} 192 | m_Layer: 0 193 | m_Name: Main Camera 194 | m_TagString: MainCamera 195 | m_Icon: {fileID: 0} 196 | m_NavMeshLayer: 0 197 | m_StaticEditorFlags: 0 198 | m_IsActive: 1 199 | --- !u!81 &658646009 200 | AudioListener: 201 | m_ObjectHideFlags: 0 202 | m_PrefabParentObject: {fileID: 0} 203 | m_PrefabInternal: {fileID: 0} 204 | m_GameObject: {fileID: 658646008} 205 | m_Enabled: 1 206 | --- !u!124 &658646010 207 | Behaviour: 208 | m_ObjectHideFlags: 0 209 | m_PrefabParentObject: {fileID: 0} 210 | m_PrefabInternal: {fileID: 0} 211 | m_GameObject: {fileID: 658646008} 212 | m_Enabled: 1 213 | --- !u!92 &658646011 214 | Behaviour: 215 | m_ObjectHideFlags: 0 216 | m_PrefabParentObject: {fileID: 0} 217 | m_PrefabInternal: {fileID: 0} 218 | m_GameObject: {fileID: 658646008} 219 | m_Enabled: 1 220 | --- !u!20 &658646012 221 | Camera: 222 | m_ObjectHideFlags: 0 223 | m_PrefabParentObject: {fileID: 0} 224 | m_PrefabInternal: {fileID: 0} 225 | m_GameObject: {fileID: 658646008} 226 | m_Enabled: 1 227 | serializedVersion: 2 228 | m_ClearFlags: 1 229 | m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} 230 | m_NormalizedViewPortRect: 231 | serializedVersion: 2 232 | x: 0 233 | y: 0 234 | width: 1 235 | height: 1 236 | near clip plane: .300000012 237 | far clip plane: 1000 238 | field of view: 60 239 | orthographic: 0 240 | orthographic size: 5 241 | m_Depth: -1 242 | m_CullingMask: 243 | serializedVersion: 2 244 | m_Bits: 4294967295 245 | m_RenderingPath: -1 246 | m_TargetTexture: {fileID: 0} 247 | m_TargetDisplay: 0 248 | m_HDR: 0 249 | m_OcclusionCulling: 1 250 | m_StereoConvergence: 10 251 | m_StereoSeparation: .0219999999 252 | --- !u!4 &658646013 253 | Transform: 254 | m_ObjectHideFlags: 0 255 | m_PrefabParentObject: {fileID: 0} 256 | m_PrefabInternal: {fileID: 0} 257 | m_GameObject: {fileID: 658646008} 258 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 259 | m_LocalPosition: {x: 0, y: 1, z: -10} 260 | m_LocalScale: {x: 1, y: 1, z: 1} 261 | m_Children: [] 262 | m_Father: {fileID: 0} 263 | m_RootOrder: 0 264 | --- !u!224 &1383673615 265 | RectTransform: 266 | m_PrefabParentObject: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, 267 | type: 2} 268 | m_PrefabInternal: {fileID: 1705696783} 269 | --- !u!114 &1383673616 270 | MonoBehaviour: 271 | m_PrefabParentObject: {fileID: 11448062, guid: b97255ee88c6e4dd58f26fc61c64d668, 272 | type: 2} 273 | m_PrefabInternal: {fileID: 1705696783} 274 | m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} 275 | --- !u!114 &1383673617 276 | MonoBehaviour: 277 | m_PrefabParentObject: {fileID: 11443752, guid: b97255ee88c6e4dd58f26fc61c64d668, 278 | type: 2} 279 | m_PrefabInternal: {fileID: 1705696783} 280 | m_Script: {fileID: 11500000, guid: 21b82da446c3542c09aa9b7ccc2f2ad7, type: 3} 281 | --- !u!1001 &1705696783 282 | Prefab: 283 | m_ObjectHideFlags: 0 284 | serializedVersion: 2 285 | m_Modification: 286 | m_TransformParent: {fileID: 170752275} 287 | m_Modifications: 288 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 289 | propertyPath: m_LocalPosition.x 290 | value: 0 291 | objectReference: {fileID: 0} 292 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 293 | propertyPath: m_LocalPosition.y 294 | value: 0 295 | objectReference: {fileID: 0} 296 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 297 | propertyPath: m_LocalPosition.z 298 | value: 0 299 | objectReference: {fileID: 0} 300 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 301 | propertyPath: m_LocalRotation.x 302 | value: 0 303 | objectReference: {fileID: 0} 304 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 305 | propertyPath: m_LocalRotation.y 306 | value: 0 307 | objectReference: {fileID: 0} 308 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 309 | propertyPath: m_LocalRotation.z 310 | value: 0 311 | objectReference: {fileID: 0} 312 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 313 | propertyPath: m_LocalRotation.w 314 | value: 1 315 | objectReference: {fileID: 0} 316 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 317 | propertyPath: m_RootOrder 318 | value: 0 319 | objectReference: {fileID: 0} 320 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 321 | propertyPath: m_AnchoredPosition.x 322 | value: 0 323 | objectReference: {fileID: 0} 324 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 325 | propertyPath: m_AnchoredPosition.y 326 | value: 0 327 | objectReference: {fileID: 0} 328 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 329 | propertyPath: m_SizeDelta.x 330 | value: 30 331 | objectReference: {fileID: 0} 332 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 333 | propertyPath: m_SizeDelta.y 334 | value: 30 335 | objectReference: {fileID: 0} 336 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 337 | propertyPath: m_AnchorMin.x 338 | value: .5 339 | objectReference: {fileID: 0} 340 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 341 | propertyPath: m_AnchorMin.y 342 | value: .5 343 | objectReference: {fileID: 0} 344 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 345 | propertyPath: m_AnchorMax.x 346 | value: .5 347 | objectReference: {fileID: 0} 348 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 349 | propertyPath: m_AnchorMax.y 350 | value: .5 351 | objectReference: {fileID: 0} 352 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 353 | propertyPath: m_Pivot.x 354 | value: .5 355 | objectReference: {fileID: 0} 356 | - target: {fileID: 22406206, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 357 | propertyPath: m_Pivot.y 358 | value: .5 359 | objectReference: {fileID: 0} 360 | - target: {fileID: 167388, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 361 | propertyPath: m_Name 362 | value: Circle 363 | objectReference: {fileID: 0} 364 | m_RemovedComponents: [] 365 | m_ParentPrefab: {fileID: 100100000, guid: b97255ee88c6e4dd58f26fc61c64d668, type: 2} 366 | m_IsPrefabParent: 0 367 | --- !u!1001 &1819241257 368 | Prefab: 369 | m_ObjectHideFlags: 0 370 | serializedVersion: 2 371 | m_Modification: 372 | m_TransformParent: {fileID: 0} 373 | m_Modifications: 374 | - target: {fileID: 447012, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 375 | propertyPath: m_LocalPosition.x 376 | value: 0 377 | objectReference: {fileID: 0} 378 | - target: {fileID: 447012, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 379 | propertyPath: m_LocalPosition.y 380 | value: 0 381 | objectReference: {fileID: 0} 382 | - target: {fileID: 447012, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 383 | propertyPath: m_LocalPosition.z 384 | value: 0 385 | objectReference: {fileID: 0} 386 | - target: {fileID: 447012, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 387 | propertyPath: m_LocalRotation.x 388 | value: 0 389 | objectReference: {fileID: 0} 390 | - target: {fileID: 447012, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 391 | propertyPath: m_LocalRotation.y 392 | value: 0 393 | objectReference: {fileID: 0} 394 | - target: {fileID: 447012, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 395 | propertyPath: m_LocalRotation.z 396 | value: 0 397 | objectReference: {fileID: 0} 398 | - target: {fileID: 447012, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 399 | propertyPath: m_LocalRotation.w 400 | value: 1 401 | objectReference: {fileID: 0} 402 | - target: {fileID: 447012, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 403 | propertyPath: m_RootOrder 404 | value: 2 405 | objectReference: {fileID: 0} 406 | - target: {fileID: 11448804, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 407 | propertyPath: DetectAcceleration 408 | value: 100 409 | objectReference: {fileID: 0} 410 | - target: {fileID: 11448804, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 411 | propertyPath: DefeatSpeed 412 | value: 10 413 | objectReference: {fileID: 0} 414 | - target: {fileID: 11448804, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 415 | propertyPath: ContinuousDetect 416 | value: 1 417 | objectReference: {fileID: 0} 418 | m_RemovedComponents: [] 419 | m_ParentPrefab: {fileID: 100100000, guid: b54aee326cf1b4bb180be1281c49861b, type: 2} 420 | m_IsPrefabParent: 0 421 | --- !u!1 &1820856009 422 | GameObject: 423 | m_ObjectHideFlags: 0 424 | m_PrefabParentObject: {fileID: 0} 425 | m_PrefabInternal: {fileID: 0} 426 | serializedVersion: 4 427 | m_Component: 428 | - 4: {fileID: 1820856013} 429 | - 114: {fileID: 1820856012} 430 | - 114: {fileID: 1820856011} 431 | - 114: {fileID: 1820856010} 432 | m_Layer: 0 433 | m_Name: EventSystem 434 | m_TagString: Untagged 435 | m_Icon: {fileID: 0} 436 | m_NavMeshLayer: 0 437 | m_StaticEditorFlags: 0 438 | m_IsActive: 1 439 | --- !u!114 &1820856010 440 | MonoBehaviour: 441 | m_ObjectHideFlags: 0 442 | m_PrefabParentObject: {fileID: 0} 443 | m_PrefabInternal: {fileID: 0} 444 | m_GameObject: {fileID: 1820856009} 445 | m_Enabled: 1 446 | m_EditorHideFlags: 0 447 | m_Script: {fileID: 1997211142, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} 448 | m_Name: 449 | m_EditorClassIdentifier: 450 | m_AllowActivationOnStandalone: 0 451 | --- !u!114 &1820856011 452 | MonoBehaviour: 453 | m_ObjectHideFlags: 0 454 | m_PrefabParentObject: {fileID: 0} 455 | m_PrefabInternal: {fileID: 0} 456 | m_GameObject: {fileID: 1820856009} 457 | m_Enabled: 1 458 | m_EditorHideFlags: 0 459 | m_Script: {fileID: 1077351063, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} 460 | m_Name: 461 | m_EditorClassIdentifier: 462 | m_HorizontalAxis: Horizontal 463 | m_VerticalAxis: Vertical 464 | m_SubmitButton: Submit 465 | m_CancelButton: Cancel 466 | m_InputActionsPerSecond: 10 467 | m_AllowActivationOnMobileDevice: 0 468 | --- !u!114 &1820856012 469 | MonoBehaviour: 470 | m_ObjectHideFlags: 0 471 | m_PrefabParentObject: {fileID: 0} 472 | m_PrefabInternal: {fileID: 0} 473 | m_GameObject: {fileID: 1820856009} 474 | m_Enabled: 1 475 | m_EditorHideFlags: 0 476 | m_Script: {fileID: -619905303, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3} 477 | m_Name: 478 | m_EditorClassIdentifier: 479 | m_FirstSelected: {fileID: 0} 480 | m_sendNavigationEvents: 1 481 | m_DragThreshold: 5 482 | --- !u!4 &1820856013 483 | Transform: 484 | m_ObjectHideFlags: 0 485 | m_PrefabParentObject: {fileID: 0} 486 | m_PrefabInternal: {fileID: 0} 487 | m_GameObject: {fileID: 1820856009} 488 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 489 | m_LocalPosition: {x: 0, y: 0, z: 0} 490 | m_LocalScale: {x: 1, y: 1, z: 1} 491 | m_Children: [] 492 | m_Father: {fileID: 0} 493 | m_RootOrder: 3 494 | --- !u!1001 &1952997472 495 | Prefab: 496 | m_ObjectHideFlags: 0 497 | serializedVersion: 2 498 | m_Modification: 499 | m_TransformParent: {fileID: 0} 500 | m_Modifications: 501 | - target: {fileID: 466334, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 502 | propertyPath: m_LocalPosition.x 503 | value: 0 504 | objectReference: {fileID: 0} 505 | - target: {fileID: 466334, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 506 | propertyPath: m_LocalPosition.y 507 | value: 0 508 | objectReference: {fileID: 0} 509 | - target: {fileID: 466334, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 510 | propertyPath: m_LocalPosition.z 511 | value: 0 512 | objectReference: {fileID: 0} 513 | - target: {fileID: 466334, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 514 | propertyPath: m_LocalRotation.x 515 | value: 0 516 | objectReference: {fileID: 0} 517 | - target: {fileID: 466334, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 518 | propertyPath: m_LocalRotation.y 519 | value: 0 520 | objectReference: {fileID: 0} 521 | - target: {fileID: 466334, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 522 | propertyPath: m_LocalRotation.z 523 | value: 0 524 | objectReference: {fileID: 0} 525 | - target: {fileID: 466334, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 526 | propertyPath: m_LocalRotation.w 527 | value: 1 528 | objectReference: {fileID: 0} 529 | - target: {fileID: 466334, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 530 | propertyPath: m_RootOrder 531 | value: 1 532 | objectReference: {fileID: 0} 533 | - target: {fileID: 11466334, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 534 | propertyPath: circleImage 535 | value: 536 | objectReference: {fileID: 1383673616} 537 | - target: {fileID: 11466334, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 538 | propertyPath: circle 539 | value: 540 | objectReference: {fileID: 1383673617} 541 | m_RemovedComponents: [] 542 | m_ParentPrefab: {fileID: 100100000, guid: c90d367bd11554b1ebd698bf8b12658d, type: 2} 543 | m_IsPrefabParent: 0 544 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/Sample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1e8353cbf1ed42abaab25b1c6114f9b 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/TouchListener.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &166334 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_PrefabParentObject: {fileID: 0} 7 | m_PrefabInternal: {fileID: 100100000} 8 | serializedVersion: 4 9 | m_Component: 10 | - 4: {fileID: 466334} 11 | - 114: {fileID: 11466334} 12 | m_Layer: 0 13 | m_Name: TouchListener 14 | m_TagString: Untagged 15 | m_Icon: {fileID: 0} 16 | m_NavMeshLayer: 0 17 | m_StaticEditorFlags: 0 18 | m_IsActive: 1 19 | --- !u!4 &466334 20 | Transform: 21 | m_ObjectHideFlags: 1 22 | m_PrefabParentObject: {fileID: 0} 23 | m_PrefabInternal: {fileID: 100100000} 24 | m_GameObject: {fileID: 166334} 25 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 26 | m_LocalPosition: {x: 0, y: 0, z: 0} 27 | m_LocalScale: {x: 1, y: 1, z: 1} 28 | m_Children: [] 29 | m_Father: {fileID: 0} 30 | m_RootOrder: 0 31 | --- !u!114 &11466334 32 | MonoBehaviour: 33 | m_ObjectHideFlags: 1 34 | m_PrefabParentObject: {fileID: 0} 35 | m_PrefabInternal: {fileID: 100100000} 36 | m_GameObject: {fileID: 166334} 37 | m_Enabled: 1 38 | m_EditorHideFlags: 0 39 | m_Script: {fileID: 11500000, guid: a8c69a45e1287467ab96b5f069e41aad, type: 3} 40 | m_Name: 41 | m_EditorClassIdentifier: 42 | circle: {fileID: 0} 43 | --- !u!1001 &100100000 44 | Prefab: 45 | m_ObjectHideFlags: 1 46 | serializedVersion: 2 47 | m_Modification: 48 | m_TransformParent: {fileID: 0} 49 | m_Modifications: [] 50 | m_RemovedComponents: [] 51 | m_ParentPrefab: {fileID: 0} 52 | m_RootGameObject: {fileID: 166334} 53 | m_IsPrefabParent: 1 54 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/TouchListener.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c90d367bd11554b1ebd698bf8b12658d 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/TouchListenerSample.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System; 4 | using System.Collections.Generic; 5 | using UnityEngine.UI; 6 | using naichilab.InputEvents; 7 | 8 | public class TouchListenerSample : MonoBehaviour 9 | { 10 | private List logs = new List (); 11 | const int MAX_LOGS = 30; 12 | public Circle circle; 13 | 14 | void OnEnable () 15 | { 16 | TouchManager.Instance.Drag += OnSwipe; 17 | TouchManager.Instance.TouchStart += OnTouchStart; 18 | TouchManager.Instance.TouchEnd += OnTouchEnd; 19 | TouchManager.Instance.FlickStart += OnFlickStart; 20 | TouchManager.Instance.FlickComplete += OnFlickComplete; 21 | } 22 | 23 | void OnDisable () 24 | { 25 | if (TouchManager.Instance != null) { 26 | TouchManager.Instance.Drag -= OnSwipe; 27 | TouchManager.Instance.TouchStart -= OnTouchStart; 28 | TouchManager.Instance.TouchEnd -= OnTouchEnd; 29 | TouchManager.Instance.FlickStart -= OnFlickStart; 30 | TouchManager.Instance.FlickComplete -= OnFlickComplete; 31 | } 32 | } 33 | 34 | void OnTouchStart (object sender, CustomInputEventArgs e) 35 | { 36 | string text = string.Format ("OnTouchStart X={0} Y={1}", e.Input.ScreenPosition.x, e.Input.ScreenPosition.y); 37 | Debug.Log (text); 38 | 39 | this.circle.Speed = Vector3.zero; 40 | this.circle.SetPosition (e.Input.ScreenPosition); 41 | } 42 | 43 | void OnTouchEnd (object sender, CustomInputEventArgs e) 44 | { 45 | string text = string.Format ("OnTouchEnd X={0} Y={1}", e.Input.ScreenPosition.x, e.Input.ScreenPosition.y); 46 | Debug.Log (text); 47 | 48 | this.circle.Speed = Vector3.zero; 49 | } 50 | 51 | void OnSwipe (object sender, CustomInputEventArgs e) 52 | { 53 | string text = string.Format ("OnSwipe Pos[{0},{1}] Move[{2},{3}]", new object[] { 54 | e.Input.ScreenPosition.x.ToString ("0"), 55 | e.Input.ScreenPosition.y.ToString ("0"), 56 | e.Input.DeltaPosition.x.ToString ("0"), 57 | e.Input.DeltaPosition.y.ToString ("0") 58 | }); 59 | 60 | this.circle.MovePosition (e.Input.DeltaPosition); 61 | } 62 | 63 | void OnFlickStart (object sender, FlickEventArgs e) 64 | { 65 | string text = string.Format ("OnFlickStart [{0}] Speed[{1}] Accel[{2}] ElapseTime[{3}]", new object[] { 66 | e.Direction.ToString (), 67 | e.Speed.ToString ("0.000"), 68 | e.Acceleration.ToString ("0.000"), 69 | e.ElapsedTime.ToString ("0.000"), 70 | }); 71 | Debug.Log (text); 72 | } 73 | 74 | void OnFlickComplete (object sender, FlickEventArgs e) 75 | { 76 | string text = string.Format ("OnFlickComplete [{0}] Speed[{1}] Accel[{2}] ElapseTime[{3}]", new object[] { 77 | e.Direction.ToString (), 78 | e.Speed.ToString ("0.000"), 79 | e.Acceleration.ToString ("0.000"), 80 | e.ElapsedTime.ToString ("0.000") 81 | }); 82 | Debug.Log (text); 83 | text = string.Format ("[{0}]->[{1}]", new object[]{ e.StartInput.ScreenPosition, e.EndInput.ScreenPosition }); 84 | Debug.Log (text); 85 | 86 | 87 | this.circle.Speed = (e.MovedDistance / e.ElapsedTime); 88 | 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Sample/TouchListenerSample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8c69a45e1287467ab96b5f069e41aad 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 258c27aae756749c4b4a9ca166c4fd0a 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/CustomInput.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace naichilab.InputEvents 5 | { 6 | public class CustomInput 7 | { 8 | public Vector3 ScreenPosition { get; set; } 9 | 10 | public Vector3 DeltaPosition { get; set; } 11 | 12 | public float DeltaTime { get; set; } 13 | 14 | public float Time{ get; set; } 15 | 16 | public bool IsDown { get; set; } 17 | 18 | public bool IsUp { get; set; } 19 | 20 | public bool IsDrag { get; set; } 21 | 22 | public int TouchId{ get; set; } 23 | 24 | public bool IsFlicking{ get; set; } 25 | 26 | /// 27 | /// 速度、加速度を計算するための平準化時間(FlickDetector.LevelingFrameCountにより決定) 28 | /// 29 | public float LevelingTime{ get; set; } 30 | 31 | /// 32 | /// このフレームの直近LevelingTimeでの移動距離 33 | /// 34 | public Vector3 MovedDistance{ get; set; } 35 | 36 | /// 37 | /// このフレームの直近LevelingTimeでの速度ベクトル 38 | /// 39 | public Vector3 SpeedVector { 40 | get { 41 | if (this.LevelingTime < 0.0001f) 42 | return Vector3.zero; 43 | return this.MovedDistance / this.LevelingTime; 44 | } 45 | } 46 | 47 | /// 48 | /// LevelingTime前のフレームの速度ベクトル 49 | /// 50 | public Vector3 LevelingOriginSpeedVector{ get; set; } 51 | 52 | /// 53 | /// このフレームの直近LevelingTimeでの加速度ベクトル 54 | /// 55 | public Vector3 AccelerationVector { 56 | get { 57 | if (this.LevelingTime < 0.0001f) 58 | return Vector3.zero; 59 | return (this.SpeedVector - this.LevelingOriginSpeedVector) / this.LevelingTime; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/CustomInput.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99d246df688f14a71b0bf86577ceee85 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/DetectGestures.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90b489fc54ef24e87b4b70d8e6741f84 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/DetectGestures/DragDetector.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace naichilab.InputEvents 5 | { 6 | public class DragDetector : MonoBehaviour,IGestureDetector 7 | { 8 | public void Enqueue (CustomInput currentInput) 9 | { 10 | if (currentInput.IsDrag) { 11 | TouchManager.Instance.OnDrag (currentInput); 12 | } 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/DetectGestures/DragDetector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62c6e9ff53c6c4922bd569b903e3179c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/DetectGestures/FlickDetector.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | 5 | namespace naichilab.InputEvents 6 | { 7 | public class FlickDetector : MonoBehaviour,IGestureDetector 8 | { 9 | /// 10 | /// フリックの検出を行うか 11 | /// 12 | public bool Enabled = true; 13 | /// 14 | /// フリック速度、加速度を計算するためのフレーム数 15 | /// 例)1を指定した場合、直前フレームと現フレームの1フレーム時間で速度、加速度を計算する。 16 | /// 17 | [Range (1f, 60f)] 18 | public int LevelingFrameCount = 5; 19 | [Range (1f, 100000f)] 20 | public float DetectAcceleration = 1000f; 21 | [Range (1f, 10000f)] 22 | public float DefeatSpeed = 100f; 23 | [Range (0f, 1000f)] 24 | public float MinFlickDistance = 0f; 25 | /// 26 | /// 指を離さなくても連続で検知するか 27 | /// 28 | /// true if continuous detect; otherwise, false. 29 | public bool ContinuousDetect = true; 30 | /// 31 | /// 過去LevelingFrameCount分のInputを保持 32 | /// 33 | private List pastInputs = new List (); 34 | /// 35 | /// フリック開始時のInput 36 | /// 37 | public CustomInput FlickStartInput = null; 38 | private bool IsDetected = false; 39 | 40 | public void Enqueue (CustomInput currentInput) 41 | { 42 | if (!(currentInput.IsDown || currentInput.IsDrag || currentInput.IsUp)) 43 | return; 44 | 45 | this.pastInputs.Add (currentInput); 46 | 47 | if (this.pastInputs.Count == 1) { 48 | //First Input 49 | currentInput.MovedDistance = Vector3.zero; 50 | currentInput.LevelingTime = 0; 51 | currentInput.LevelingOriginSpeedVector = Vector3.zero; 52 | } else { 53 | //currentInputからLevelingFrame数だけ古いフレームのInput 54 | CustomInput levelingOriginInput = this.pastInputs [0]; 55 | currentInput.MovedDistance = currentInput.ScreenPosition - levelingOriginInput.ScreenPosition; 56 | currentInput.LevelingTime = currentInput.Time - levelingOriginInput.Time;// this.LevelingFrameCount; 57 | currentInput.LevelingOriginSpeedVector = levelingOriginInput.SpeedVector; 58 | 59 | //フリック開始&継続判定 60 | var lastInput = this.pastInputs [this.pastInputs.Count - 2]; 61 | if (lastInput.IsFlicking) { 62 | //継続判定 63 | if (currentInput.SpeedVector.magnitude > this.DefeatSpeed) { 64 | currentInput.IsFlicking = true; 65 | } else { 66 | //フリック中止 67 | this.FlickStartInput = null; 68 | 69 | currentInput.IsFlicking = false; 70 | this.FlickStartInput = null; 71 | } 72 | } else { 73 | //フリック開始判定 74 | if (currentInput.AccelerationVector.magnitude > this.DetectAcceleration) { 75 | if (currentInput.SpeedVector.magnitude > 0.0001f) { 76 | if (!this.ContinuousDetect && this.IsDetected) { 77 | //指を離すまで再検知しない 78 | } else { 79 | currentInput.IsFlicking = true; 80 | this.FlickStartInput = currentInput; 81 | this.IsDetected = true; 82 | //フリック開始イベント 83 | TouchManager.Instance.OnFlickStart (new FlickEventArgs (levelingOriginInput, currentInput)); 84 | } 85 | } 86 | } 87 | } 88 | 89 | //フリック完了判定 90 | if (currentInput.IsFlicking && currentInput.IsUp) { 91 | 92 | Vector3 flickDistance = currentInput.ScreenPosition - this.FlickStartInput.ScreenPosition; 93 | if (flickDistance.magnitude > this.MinFlickDistance) { 94 | 95 | //フリック成立 96 | TouchManager.Instance.OnFlickComplete (new FlickEventArgs (this.pastInputs [this.pastInputs.Count - 2], currentInput)); 97 | //TouchManager.Instance.OnFlickComplete (new FlickEventArgs (this.FlickStartInput, currentInput)); 98 | 99 | currentInput.IsFlicking = false; 100 | this.FlickStartInput = null; 101 | 102 | } 103 | } 104 | 105 | //指が離れた 106 | if (currentInput.IsUp) { 107 | this.IsDetected = false; 108 | this.pastInputs.Clear(); 109 | } 110 | } 111 | 112 | while (this.pastInputs.Count > this.LevelingFrameCount) { 113 | this.pastInputs.RemoveAt (0); 114 | } 115 | 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/DetectGestures/FlickDetector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e479e77d3d5147bcbdb68359450bf5c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/DetectGestures/IGestureDetector.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace naichilab.InputEvents 5 | { 6 | public interface IGestureDetector 7 | { 8 | void Enqueue (CustomInput currentInput); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/DetectGestures/IGestureDetector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cdde609fcb454b3ab0072063a27247d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/DetectGestures/TouchDetector.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | namespace naichilab.InputEvents 5 | { 6 | public class TouchDetector : MonoBehaviour,IGestureDetector 7 | { 8 | public void Enqueue (CustomInput currentInput) 9 | { 10 | if (currentInput.IsDown) { 11 | TouchManager.Instance.OnTouchStart (currentInput); 12 | } 13 | if (currentInput.IsUp) { 14 | TouchManager.Instance.OnTouchEnd (currentInput); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/DetectGestures/TouchDetector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7eba50494cb2a4696a818eedaa9abfa8 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/Events.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b45b9fdf69e054719a869727f0b3ef41 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/Events/CustomInputEventArgs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System; 4 | 5 | namespace naichilab.InputEvents 6 | { 7 | public class CustomInputEventArgs : EventArgs 8 | { 9 | public CustomInput Input{ get; private set; } 10 | 11 | public CustomInputEventArgs (CustomInput input) 12 | { 13 | this.Input = input; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/Events/CustomInputEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a89d5cd6d71f437faa69031bf027054 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/Events/FlickEventArgs.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System; 4 | 5 | namespace naichilab.InputEvents 6 | { 7 | public class FlickEventArgs : EventArgs 8 | { 9 | public enum Direction4 10 | { 11 | None = -1, 12 | Up = 0, 13 | Left = 1, 14 | Down = 2, 15 | Right = 3 16 | } 17 | 18 | public CustomInput StartInput{ get; private set; } 19 | 20 | public CustomInput EndInput{ get; private set; } 21 | 22 | public Vector3 MovedDistance{ get { return EndInput.ScreenPosition - StartInput.ScreenPosition; } } 23 | 24 | public float ElapsedTime{ get { return EndInput.Time - StartInput.Time; } } 25 | 26 | public float Speed { 27 | get { 28 | if (this.ElapsedTime < 0.0001f) 29 | return 0; 30 | return this.MovedDistance.magnitude / this.ElapsedTime; 31 | } 32 | } 33 | 34 | public Direction4 Direction{ get { return VectorDirection4 (this.MovedDistance.x, this.MovedDistance.y); } } 35 | 36 | public float Acceleration { 37 | get { 38 | if (this.ElapsedTime < 0.0001f) 39 | return 0; 40 | return (this.EndInput.AccelerationVector - this.StartInput.AccelerationVector).magnitude / this.ElapsedTime; 41 | } 42 | } 43 | 44 | public FlickEventArgs (CustomInput startInput, CustomInput endInput) 45 | { 46 | this.StartInput = startInput; 47 | this.EndInput = endInput; 48 | } 49 | 50 | private static Direction4 VectorDirection4 (float x, float y) 51 | { 52 | if (y == 0 && x == 0) 53 | return Direction4.None; 54 | 55 | if (y >= Mathf.Abs (x)) 56 | return Direction4.Up; 57 | if (y <= -Mathf.Abs (x)) 58 | return Direction4.Down; 59 | 60 | if (x < -Mathf.Abs (y)) 61 | return Direction4.Left; 62 | if (x > Mathf.Abs (y)) 63 | return Direction4.Right; 64 | 65 | return Direction4.None; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/Events/FlickEventArgs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5335bd248897f4f7d9284ab2ee442b8d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/TouchManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | 6 | namespace naichilab.InputEvents 7 | { 8 | [RequireComponent (typeof(TouchDetector))] 9 | [RequireComponent (typeof(DragDetector))] 10 | [RequireComponent (typeof(FlickDetector))] 11 | public class TouchManager :MonoBehaviour 12 | { 13 | public event EventHandler TouchStart; 14 | public event EventHandler TouchEnd; 15 | public event EventHandler Drag; 16 | public event EventHandler FlickComplete; 17 | public event EventHandler FlickStart; 18 | 19 | public void OnTouchStart (CustomInput input) 20 | { 21 | if (this.TouchStart != null) 22 | this.TouchStart (this.gameObject, new CustomInputEventArgs (input)); 23 | } 24 | 25 | public void OnTouchEnd (CustomInput input) 26 | { 27 | if (this.TouchEnd != null) 28 | this.TouchEnd (this.gameObject, new CustomInputEventArgs (input)); 29 | } 30 | 31 | public void OnDrag (CustomInput input) 32 | { 33 | if (this.Drag != null) 34 | this.Drag (this.gameObject, new CustomInputEventArgs (input)); 35 | } 36 | 37 | public void OnFlickComplete (FlickEventArgs e) 38 | { 39 | if (this.FlickComplete != null) 40 | this.FlickComplete (this.gameObject, e); 41 | } 42 | 43 | public void OnFlickStart (FlickEventArgs e) 44 | { 45 | if (this.FlickStart != null) 46 | this.FlickStart (this.gameObject, e); 47 | } 48 | 49 | #region Singleton 50 | 51 | private static TouchManager instance; 52 | 53 | public static TouchManager Instance { 54 | get { 55 | if (instance == null) { 56 | instance = (TouchManager)FindObjectOfType (typeof(TouchManager)); 57 | 58 | if (instance == null) { 59 | Debug.LogWarning (typeof(TouchManager) + "is nothing"); 60 | } 61 | } 62 | return instance; 63 | } 64 | } 65 | 66 | #endregion Singleton 67 | 68 | private List Detectors = new List (); 69 | private CustomInput lastInput = null; 70 | public bool DebugMode = false; 71 | 72 | private static bool IsTouchPlatform { 73 | get { 74 | switch (Application.platform) { 75 | case RuntimePlatform.Android: 76 | case RuntimePlatform.IPhonePlayer: 77 | return true; 78 | default: 79 | return false; 80 | } 81 | } 82 | } 83 | 84 | private Touch? CurrentTouch { 85 | get { 86 | if (Input.touchCount <= 0) { 87 | return null; 88 | } 89 | if (this.lastInput == null) { 90 | foreach (var touch in Input.touches) { 91 | if (touch.phase == TouchPhase.Began) { 92 | return touch; 93 | } 94 | } 95 | } else { 96 | foreach (var touch in Input.touches) { 97 | if (touch.fingerId == this.lastInput.TouchId) { 98 | return touch; 99 | } 100 | } 101 | } 102 | return null; 103 | } 104 | } 105 | 106 | private CustomInput InputOfTouch { 107 | get { 108 | CustomInput input = new CustomInput (); 109 | input.Time = Time.time; 110 | 111 | Touch? touch = this.CurrentTouch; 112 | 113 | if (!touch.HasValue) { 114 | return input; 115 | } 116 | input.ScreenPosition = touch.Value.position; 117 | input.DeltaPosition = touch.Value.deltaPosition; 118 | input.TouchId = touch.Value.fingerId; 119 | if (this.lastInput != null) { 120 | input.DeltaTime = Time.time - this.lastInput.Time; 121 | } 122 | switch (touch.Value.phase) { 123 | case TouchPhase.Began: 124 | input.IsDown = true; 125 | break; 126 | case TouchPhase.Moved: 127 | case TouchPhase.Stationary: 128 | input.IsDrag = true; 129 | break; 130 | case TouchPhase.Ended: 131 | case TouchPhase.Canceled: 132 | input.IsUp = true; 133 | break; 134 | } 135 | return input; 136 | } 137 | } 138 | 139 | private CustomInput InputOfMouse { 140 | get { 141 | CustomInput input = new CustomInput (); 142 | input.ScreenPosition = Input.mousePosition; 143 | input.Time = Time.time; 144 | if (this.lastInput != null) { 145 | input.DeltaPosition = Input.mousePosition - lastInput.ScreenPosition; 146 | input.DeltaTime = Time.time - this.lastInput.Time; 147 | } 148 | if (Input.GetMouseButtonDown (0)) { 149 | input.IsDown = true; 150 | input.DeltaPosition = new Vector3 (); 151 | } else if (Input.GetMouseButtonUp (0)) { 152 | input.IsUp = true; 153 | } else if (Input.GetMouseButton (0)) { 154 | input.IsDrag = true; 155 | } 156 | return input; 157 | } 158 | } 159 | 160 | private void Awake () 161 | { 162 | if (this != Instance) { 163 | Destroy (this); 164 | return; 165 | } 166 | DontDestroyOnLoad (this.gameObject); 167 | } 168 | 169 | private void Start () 170 | { 171 | this.Detectors.Add (this.GetComponent ()); 172 | this.Detectors.Add (this.GetComponent ()); 173 | this.Detectors.Add (this.GetComponent ()); 174 | } 175 | 176 | private void Update () 177 | { 178 | CustomInput currentInput = IsTouchPlatform ? InputOfTouch : InputOfMouse; 179 | 180 | foreach (var detector in this.Detectors) { 181 | detector.Enqueue (currentInput); 182 | } 183 | 184 | this.lastInput = currentInput; 185 | } 186 | 187 | public void OnGUI () 188 | { 189 | if (!this.DebugMode) 190 | return; 191 | CustomInput input = this.lastInput; 192 | if (input == null) { 193 | input = new CustomInput (); 194 | } 195 | 196 | int i = 0; 197 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("ScreenPosition : X:{0} Y:{1}", input.ScreenPosition.x.ToString ("0"), input.ScreenPosition.y.ToString ("0"))); 198 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("DeltaPosition : X:{0} Y:{1}", input.DeltaPosition.x.ToString ("0"), input.DeltaPosition.y.ToString ("0"))); 199 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("DeltaTime : {0}sec", input.DeltaTime.ToString ("0.000"))); 200 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("Time : {0}sec", input.Time.ToString ("0.000"))); 201 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("IsDown : {0}", input.IsDown.ToString ())); 202 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("IsUp : {0}", input.IsUp.ToString ())); 203 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("IsDrag : {0}", input.IsDrag.ToString ())); 204 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("IsFlicking : {0}", input.IsFlicking.ToString ())); 205 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("TouchID : {0}", input.TouchId)); 206 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("", "")); 207 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("LevelingTime : {0}sec", input.LevelingTime.ToString ("0.000"))); 208 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("MovedDistance : {0}", input.MovedDistance.magnitude)); 209 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("Speed : {0} [X:{1},Y:{2}]", input.SpeedVector.magnitude, input.SpeedVector.x.ToString ("0"), input.SpeedVector.y.ToString ("0"))); 210 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("LevelingOriginSpeed : {0} [X:{1},Y:{2}]", input.LevelingOriginSpeedVector.magnitude, input.LevelingOriginSpeedVector.x.ToString ("0"), input.LevelingOriginSpeedVector.y.ToString ("0"))); 211 | GUI.Label (new Rect (20, 20 + i++ * 20, 400, 20), string.Format ("Acceleration : {0} [X:{1},Y:{2}]", input.AccelerationVector.magnitude, input.AccelerationVector.x.ToString ("0"), input.AccelerationVector.y.ToString ("0"))); 212 | 213 | 214 | } 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /Assets/naichilab/TouchManager/Scripts/TouchManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c36263aaa51f44299222467462737cb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 naichi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.6.1f1 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Unity-TouchManager 2 | ==== 3 | 4 | マウス/タッチ操作による一般的なジェスチャーをシンプルなコードで利用可能にするアセット(になる予定) 5 | 6 | * WebPlayerでのマウス操作およびiPhone,Androidでのタッチ操作を等しく扱えます。 7 | * タッチ操作はシングルタッチのみ対応(必要になったらマルチタッチ対応します) 8 | * 扱える操作 9 | * タッチ開始(マウスクリックを開始) 10 | * タッチ終了(マウスクリックを離す) 11 | * ドラッグ(スワイプ) 12 | * フリック開始(マウスドラッグ開始) 13 | * フリック(マウスドラッグしながら離す) 14 | 15 | ## デモ 16 | 17 | ## インストール 18 | 1. TouchManager.unitypackageをインポート 19 | 20 | ## 使用方法 21 | 1. TouchManager.prefabをシーンに配置 22 | 2. タッチイベントを受け取りたいスクリプト上で下記を記述 23 | 24 | 下記ソースは TouchListener.prefab にサンプルとして書かれています。 25 | 26 | ### モジュールの読み込み 27 | ```csharp 28 | using naichilab.InputEvents; 29 | ``` 30 | 31 | ### タッチ開始を取得 32 | ```csharp 33 | void OnEnable () 34 | { 35 | TouchManager.Instance.TouchStart += OnTouchStart; 36 | } 37 | void OnDisable () 38 | { 39 | TouchManager.Instance.TouchStart -= OnTouchStart; 40 | } 41 | void OnTouchStart (object sender, CustomInputEventArgs e) 42 | { 43 | string text = string.Format ("OnTouchStart X={0} Y={1}", e.Input.ScreenPosition.x, e.Input.ScreenPosition.y); 44 | Debug.Log (text); 45 | } 46 | ``` 47 | ### タッチ終了を取得 48 | ```csharp 49 | void OnEnable () 50 | { 51 | TouchManager.Instance.TouchEnd += OnTouchEnd; 52 | } 53 | void OnDisable () 54 | { 55 | TouchManager.Instance.TouchEnd -= OnTouchEnd; 56 | } 57 | void OnTouchEnd (object sender, CustomInputEventArgs e) 58 | { 59 | string text = string.Format ("OnTouchEnd X={0} Y={1}", e.Input.ScreenPosition.x, e.Input.ScreenPosition.y); 60 | Debug.Log (text); 61 | } 62 | ``` 63 | ### ドラッグを取得 64 | ```csharp 65 | void OnEnable () 66 | { 67 | TouchManager.Instance.Drag += OnDrag; 68 | } 69 | void OnDisable () 70 | { 71 | TouchManager.Instance.Drag -= OnDrag; 72 | } 73 | void OnDrag (object sender, CustomInputEventArgs e) 74 | { 75 | string text = string.Format ("OnSwipe Pos[{0},{1}] Move[{2},{3}]", new object[] { 76 | e.Input.ScreenPosition.x.ToString ("0"), 77 | e.Input.ScreenPosition.y.ToString ("0"), 78 | e.Input.DeltaPosition.x.ToString ("0"), 79 | e.Input.DeltaPosition.y.ToString ("0") 80 | }); 81 | Debug.Log (text); 82 | } 83 | ``` 84 | ### フリック開始を取得 85 | ```csharp 86 | void OnEnable () 87 | { 88 | TouchManager.Instance.FlickStart += OnFlickStart; 89 | } 90 | void OnDisable () 91 | { 92 | TouchManager.Instance.FlickStart -= OnFlickStart; 93 | } 94 | void OnFlickStart (object sender, FlickEventArgs e) 95 | { 96 | string text = string.Format ("OnFlickStart [{0}] Speed[{1}] Accel[{2}] ElapseTime[{3}]", new object[] { 97 | e.Direction.ToString (), 98 | e.Speed.ToString ("0.000"), 99 | e.Acceleration.ToString ("0.000"), 100 | e.ElapsedTime.ToString ("0.000"), 101 | }); 102 | Debug.Log (text); 103 | } 104 | ``` 105 | ### フリックを取得 106 | ```csharp 107 | void OnEnable () 108 | { 109 | TouchManager.Instance.FlickComplete += OnFlickComplete; 110 | } 111 | void OnDisable () 112 | { 113 | TouchManager.Instance.FlickComplete -= OnFlickComplete; 114 | } 115 | void OnFlickComplete (object sender, FlickEventArgs e) 116 | { 117 | string text = string.Format ("OnFlickComplete [{0}] Speed[{1}] Accel[{2}] ElapseTime[{3}]", new object[] { 118 | e.Direction.ToString (), 119 | e.Speed.ToString ("0.000"), 120 | e.Acceleration.ToString ("0.000"), 121 | e.ElapsedTime.ToString ("0.000") 122 | }); 123 | Debug.Log (text); 124 | } 125 | ``` 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | ## Contribution 134 | 135 | 1. Fork it ( https://github.com/naichilab/Unity-TouchManager/fork ) 136 | 2. Create your feature branch (git checkout -b my-new-feature) 137 | 3. Commit your changes (git commit -am 'Add some feature') 138 | 4. Push to the branch (git push origin my-new-feature) 139 | 5. Create new Pull Request 140 | 141 | ## Licence 142 | This software is released under the MIT License, see LICENSE.txt. 143 | [MIT](https://github.com/naichilab/Unity-TouchManager/blob/master/LICENSE) 144 | 145 | ## 作者 146 | [@naichilab](https://github.com/naichilab) 147 | -------------------------------------------------------------------------------- /TouchManager.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/naichilab/Unity-TouchManager/f3cb05f044a44807faae76ca2c6345458ce73f19/TouchManager.unitypackage --------------------------------------------------------------------------------