diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj
new file mode 100644
index 0000000..3d131e1
--- /dev/null
+++ b/Assembly-CSharp.csproj
@@ -0,0 +1,66 @@
+
+
+
+ Debug
+ AnyCPU
+ 10.0.20506
+ 2.0
+
+ {06515F97-C670-B94C-8141-437BF7EAD910}
+ Library
+ Properties
+ Assembly-CSharp
+ v3.5
+ 512
+ Assets
+
+
+ true
+ full
+ false
+ Temp\bin\Debug\
+ DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_4_2;UNITY_5_4;UNITY_5;UNITY_64;ENABLE_NEW_BUGREPORTER;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_EDITOR_RETINA;ENABLE_RETINA_GUISTYLES;ENABLE_FRAME_DEBUGGER;ENABLE_GENERICS;ENABLE_HOME_SCREEN;ENABLE_IMAGEEFFECTS;ENABLE_LIGHT_PROBES_LEGACY;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_PLUGIN_INSPECTOR;ENABLE_SHADOWS;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_SPRITE_POLYGON;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_UNITYEVENTS;ENABLE_VR;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;INCLUDE_IL2CPP;INCLUDE_DIRECTX12;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;INCLUDE_PUBNUB;ENABLE_LOCALIZATION;ENABLE_ANDROID_ATLAS_ETC1_COMPRESSION;ENABLE_EDITOR_TESTS_RUNNER;UNITY_STANDALONE_OSX;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_GAMECENTER;ENABLE_TEXTUREID_MAP;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_CLUSTERINPUT;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_OSX;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE
+ prompt
+ 4
+ 0169
+
+
+ pdbonly
+ true
+ Temp\bin\Release\
+ prompt
+ 4
+ 0169
+
+
+
+
+
+
+
+ /Applications/Unity/Unity.app/Contents/Managed/UnityEngine.dll
+
+
+ /Applications/Unity/Unity.app/Contents/Managed/UnityEditor.dll
+
+
+
+
+
+
+ /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll
+
+
+ /Applications/Unity/Unity.app/Contents/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll
+
+
+
+
+
+
diff --git a/SwipeManager.cs b/Assets/SwipeManager.cs
similarity index 81%
rename from SwipeManager.cs
rename to Assets/SwipeManager.cs
index acea911..b08fec3 100644
--- a/SwipeManager.cs
+++ b/Assets/SwipeManager.cs
@@ -27,12 +27,15 @@ public enum Swipes { None, Up, Down, Left, TopLeft, BottomLeft, Right, TopRight,
public class SwipeManager : MonoBehaviour
{
public float minSwipeLength = 200f;
- Vector2 currentSwipe;
-
+
private Vector2 fingerStart;
private Vector2 fingerEnd;
public static Swipes direction;
+ public static float angle;
+ public static Vector2 strength;
+
+ public static bool debugMode = false;
void Update ()
{
@@ -49,48 +52,48 @@ public void SwipeDetection ()
if(Input.GetMouseButton(0)) {
fingerEnd = Input.mousePosition;
- currentSwipe = new Vector2 (fingerEnd.x - fingerStart.x, fingerEnd.y - fingerStart.y);
+ strength = new Vector2 (fingerEnd.x - fingerStart.x, fingerEnd.y - fingerStart.y);
// Make sure it was a legit swipe, not a tap
- if (currentSwipe.magnitude < minSwipeLength) {
+ if (strength.magnitude < minSwipeLength) {
direction = Swipes.None;
return;
}
- float angle = (Mathf.Atan2(currentSwipe.y, currentSwipe.x) / (Mathf.PI));
- Debug.Log(angle);
+ angle = (Mathf.Atan2(strength.y, strength.x) / (Mathf.PI));
+ if (debugMode) Debug.Log(angle);
// Swipe up
if (angle>0.375f && angle<0.625f) {
direction = Swipes.Up;
- Debug.Log ("Up");
+ if (debugMode) Debug.Log ("Up");
// Swipe down
} else if (angle<-0.375f && angle>-0.625f) {
direction = Swipes.Down;
- Debug.Log ("Down");
+ if (debugMode) Debug.Log ("Down");
// Swipe left
} else if (angle<-0.875f || angle>0.875f) {
direction = Swipes.Left;
- Debug.Log ("Left");
+ if (debugMode) Debug.Log ("Left");
// Swipe right
} else if (angle>-0.125f && angle<0.125f) {
direction = Swipes.Right;
- Debug.Log ("Right");
+ if (debugMode) Debug.Log ("Right");
}
else if(angle>0.125f && angle<0.375f){
direction = Swipes.TopRight;
- Debug.Log ("top right");
+ if (debugMode) Debug.Log ("top right");
}
else if(angle>0.625f && angle<0.875f){
direction = Swipes.TopLeft;
- Debug.Log ("top left");
+ if (debugMode) Debug.Log ("top left");
}
else if(angle<-0.125f && angle>-0.375f){
direction = Swipes.BottomRight;
- Debug.Log ("bottom right");
+ if (debugMode) Debug.Log ("bottom right");
}
else if(angle<-0.625f && angle>-0.875f){
direction = Swipes.BottomLeft;
- Debug.Log ("bottom left");
+ if (debugMode) Debug.Log ("bottom left");
}
}
diff --git a/Assets/SwipeManager.cs.meta b/Assets/SwipeManager.cs.meta
new file mode 100644
index 0000000..fed99c6
--- /dev/null
+++ b/Assets/SwipeManager.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 34a58dd2d332f41959a8f3ce52086d6f
+timeCreated: 1478875235
+licenseType: Pro
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/demo.cs b/Assets/demo.cs
new file mode 100644
index 0000000..30cc279
--- /dev/null
+++ b/Assets/demo.cs
@@ -0,0 +1,26 @@
+using UnityEngine;
+using UnityEngine.UI;
+using System.Collections;
+
+public class demo : MonoBehaviour {
+
+ public GameObject obj;
+ public Text txt1;
+
+ // Use this for initialization
+ void Start () {
+
+ }
+
+ // Update is called once per frame
+ void Update () {
+
+ obj.transform.rotation = new Quaternion (1, 1, SwipeManager.angle, 1);
+ obj.transform.localScale = new Vector3 (SwipeManager.strength.x/100, SwipeManager.strength.y/100, 1);
+
+ if (SwipeManager.direction != Swipes.None) {
+ txt1.text = SwipeManager.direction + "\t\t\t A: "+SwipeManager.angle+"\t\t\t S: "+SwipeManager.strength+"\n" + txt1.text;
+ }
+
+ }
+}
diff --git a/Assets/demo.cs.meta b/Assets/demo.cs.meta
new file mode 100644
index 0000000..1f1898c
--- /dev/null
+++ b/Assets/demo.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 88b2ec853d4d74808a84d949a820c5dc
+timeCreated: 1478875252
+licenseType: Pro
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/demo.unity b/Assets/demo.unity
new file mode 100644
index 0000000..1de9712
Binary files /dev/null and b/Assets/demo.unity differ
diff --git a/Assets/demo.unity.meta b/Assets/demo.unity.meta
new file mode 100644
index 0000000..7c5eba3
--- /dev/null
+++ b/Assets/demo.unity.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 8e82ef72f441a420f9fceb382bb7731c
+timeCreated: 1478875121
+licenseType: Pro
+DefaultImporter:
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/ProjectSettings/AudioManager.asset b/ProjectSettings/AudioManager.asset
new file mode 100644
index 0000000..4ee79b6
Binary files /dev/null and b/ProjectSettings/AudioManager.asset differ
diff --git a/ProjectSettings/ClusterInputManager.asset b/ProjectSettings/ClusterInputManager.asset
new file mode 100644
index 0000000..ce777b2
Binary files /dev/null and b/ProjectSettings/ClusterInputManager.asset differ
diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset
new file mode 100644
index 0000000..8c0393c
Binary files /dev/null and b/ProjectSettings/DynamicsManager.asset differ
diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset
new file mode 100644
index 0000000..f7e9ef2
Binary files /dev/null and b/ProjectSettings/EditorBuildSettings.asset differ
diff --git a/ProjectSettings/EditorSettings.asset b/ProjectSettings/EditorSettings.asset
new file mode 100644
index 0000000..6da9577
Binary files /dev/null and b/ProjectSettings/EditorSettings.asset differ
diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset
new file mode 100644
index 0000000..7c06a0f
Binary files /dev/null and b/ProjectSettings/GraphicsSettings.asset differ
diff --git a/ProjectSettings/InputManager.asset b/ProjectSettings/InputManager.asset
new file mode 100644
index 0000000..4df10fc
Binary files /dev/null and b/ProjectSettings/InputManager.asset differ
diff --git a/ProjectSettings/NavMeshAreas.asset b/ProjectSettings/NavMeshAreas.asset
new file mode 100644
index 0000000..1039709
Binary files /dev/null and b/ProjectSettings/NavMeshAreas.asset differ
diff --git a/ProjectSettings/NetworkManager.asset b/ProjectSettings/NetworkManager.asset
new file mode 100644
index 0000000..213e846
Binary files /dev/null and b/ProjectSettings/NetworkManager.asset differ
diff --git a/ProjectSettings/Physics2DSettings.asset b/ProjectSettings/Physics2DSettings.asset
new file mode 100644
index 0000000..51cf97a
Binary files /dev/null and b/ProjectSettings/Physics2DSettings.asset differ
diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset
new file mode 100644
index 0000000..f9ed6e0
Binary files /dev/null and b/ProjectSettings/ProjectSettings.asset differ
diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt
new file mode 100644
index 0000000..727b74d
--- /dev/null
+++ b/ProjectSettings/ProjectVersion.txt
@@ -0,0 +1,2 @@
+m_EditorVersion: 5.4.2f1
+m_StandardAssetsVersion: 0
diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset
new file mode 100644
index 0000000..c70a443
Binary files /dev/null and b/ProjectSettings/QualitySettings.asset differ
diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset
new file mode 100644
index 0000000..829070c
Binary files /dev/null and b/ProjectSettings/TagManager.asset differ
diff --git a/ProjectSettings/TimeManager.asset b/ProjectSettings/TimeManager.asset
new file mode 100644
index 0000000..f7f7ea2
Binary files /dev/null and b/ProjectSettings/TimeManager.asset differ
diff --git a/ProjectSettings/UnityAdsSettings.asset b/ProjectSettings/UnityAdsSettings.asset
new file mode 100644
index 0000000..fea85c4
Binary files /dev/null and b/ProjectSettings/UnityAdsSettings.asset differ
diff --git a/ProjectSettings/UnityConnectSettings.asset b/ProjectSettings/UnityConnectSettings.asset
new file mode 100644
index 0000000..9e90961
Binary files /dev/null and b/ProjectSettings/UnityConnectSettings.asset differ
diff --git a/README.md b/README.md
index cb4de03..eb8da26 100644
--- a/README.md
+++ b/README.md
@@ -2,3 +2,11 @@
Finger gesture detection in 8 direction using unity C#
This class has been designed to detect finger swipe in 8 different direction across device's screen.
+
+
+
+# 11 Nov 2016
+
+- Added public variables for swipe strength and angle.
+
+- Added unity demo project
diff --git a/SwipeManager.sln b/SwipeManager.sln
new file mode 100644
index 0000000..09d2b63
--- /dev/null
+++ b/SwipeManager.sln
@@ -0,0 +1,23 @@
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2008
+
+Project("{A2789334-E086-3646-F573-647C11DDECF5}") = "SwipeManager", "Assembly-CSharp.csproj", "{06515F97-C670-B94C-8141-437BF7EAD910}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {06515F97-C670-B94C-8141-437BF7EAD910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {06515F97-C670-B94C-8141-437BF7EAD910}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {06515F97-C670-B94C-8141-437BF7EAD910}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {06515F97-C670-B94C-8141-437BF7EAD910}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = Assembly-CSharp.csproj
+ EndGlobalSection
+EndGlobal
diff --git a/SwipeManager.userprefs b/SwipeManager.userprefs
new file mode 100644
index 0000000..6134335
--- /dev/null
+++ b/SwipeManager.userprefs
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file