private static void DrawSettings(LeanTouch touch) { EditorGUI.LabelField(Reserve(), "Settings", EditorStyles.boldLabel); touch.TapThreshold = EditorGUILayout.FloatField("Tap Threshold", touch.TapThreshold); touch.SwipeThreshold = EditorGUILayout.FloatField("Swipe Threshold", touch.SwipeThreshold); touch.HeldThreshold = EditorGUILayout.FloatField("Held Threshold", touch.HeldThreshold); touch.ReferenceDpi = EditorGUILayout.IntField("Reference DPI", touch.ReferenceDpi); EditorGUILayout.Separator(); touch.RecordFingers = EditorGUILayout.Toggle("Record Fingers", touch.RecordFingers); if (touch.RecordFingers == true) { EditorGUI.indentLevel += 1; { touch.RecordThreshold = EditorGUILayout.FloatField("Record Threshold", touch.RecordThreshold); touch.RecordLimit = EditorGUILayout.FloatField("Record Limit", touch.RecordLimit); } EditorGUI.indentLevel -= 1; } EditorGUILayout.Separator(); touch.SimulateMultiFingers = EditorGUILayout.Toggle("Simulate Multi Fingers", touch.SimulateMultiFingers); if (touch.SimulateMultiFingers == true) { EditorGUI.indentLevel += 1; { touch.PinchTwistKey = (KeyCode)EditorGUILayout.EnumPopup("Pinch Twist Key", touch.PinchTwistKey); touch.MultiDragKey = (KeyCode)EditorGUILayout.EnumPopup("Multi Drag Key", touch.MultiDragKey); touch.FingerTexture = (Texture2D)EditorGUI.ObjectField(Reserve(), "Touch Texture", touch.FingerTexture, typeof(Texture2D), true); } EditorGUI.indentLevel -= 1; } }
private static void DrawFingers(LeanTouch touch) { EditorGUI.LabelField(Reserve(), "Fingers", EditorStyles.boldLabel); allFingers.Clear(); allFingers.AddRange(LeanTouch.Fingers); allFingers.AddRange(LeanTouch.InactiveFingers); allFingers.Sort((a, b) => a.Index.CompareTo(b.Index)); for (var i = 0; i < allFingers.Count; i++) { var finger = allFingers[i]; var progress = touch.TapThreshold > 0.0f ? finger.Age / touch.TapThreshold : 0.0f; var style = GetFadingLabel(finger.Set, progress); if (style.normal.textColor.a > 0.0f) { var screenPosition = finger.ScreenPosition; EditorGUILayout.LabelField("#" + finger.Index + " x " + finger.TapCount + " (" + Mathf.FloorToInt(screenPosition.x) + ", " + Mathf.FloorToInt(screenPosition.y) + ") - " + finger.Age.ToString("0.0"), style); } } }
private void DrawSettings(LeanTouch touch) { DrawTitle("Settings"); DrawDefault("TapThreshold"); DrawDefault("SwipeThreshold"); DrawDefault("HeldThreshold"); DrawDefault("ReferenceDpi"); Separator(); DrawDefault("RecordFingers"); if (touch.RecordFingers == true) { BeginIndent(); { DrawDefault("RecordThreshold"); DrawDefault("RecordLimit"); } EndIndent(); } Separator(); DrawDefault("SimulateMultiFingers"); if (touch.SimulateMultiFingers == true) { BeginIndent(); { DrawDefault("PinchTwistKey"); DrawDefault("MultiDragKey"); DrawDefault("FingerTexture"); } EndIndent(); } }
protected virtual void OnEnable() { // Make sure there's only one LeanTouch active in the scene if (Instance != null && Instance != this) { Debug.LogWarning("Your scene already contains a " + typeof(LeanTouch).Name + ", destroying the old one..."); DestroyImmediate(Instance.gameObject); } Instance = this; #if UNITY_EDITOR // Set the finger texture? if (FingerTexture == null) { var guids = UnityEditor.AssetDatabase.FindAssets("FingerVisualization t:texture2d"); if (guids.Length > 0) { var path = UnityEditor.AssetDatabase.GUIDToAssetPath(guids[0]); FingerTexture = UnityEditor.AssetDatabase.LoadMainAssetAtPath(path) as Texture2D; } } #endif }