Skip to content
Permalink
Browse files

Added Basic and Advanced views to most components.

  • Loading branch information...
valyard committed Jul 25, 2017
1 parent 73a3799 commit 8dd43399e1d1f873ca1f4089cb62eee8b0234c31
Showing with 1,066 additions and 412 deletions.
  1. 0 Source/Assets/TouchScript/Editor/Behaviors/{Visualizer.meta → Cursors.meta}
  2. +70 −0 Source/Assets/TouchScript/Editor/Behaviors/Cursors/CursorManagerEditor.cs
  3. +12 −0 Source/Assets/TouchScript/Editor/Behaviors/Cursors/CursorManagerEditor.cs.meta
  4. +3 −5 Source/Assets/TouchScript/Editor/Behaviors/TransformerEditor.cs
  5. +24 −0 Source/Assets/TouchScript/Editor/EditorUI/GUIElements.cs
  6. +15 −11 Source/Assets/TouchScript/Editor/Gestures/FlickGestureEditor.cs
  7. +70 −47 Source/Assets/TouchScript/Editor/Gestures/GestureEditor.cs
  8. +13 −1 Source/Assets/TouchScript/Editor/Gestures/LongPressGestureEditor.cs
  9. +28 −0 Source/Assets/TouchScript/Editor/Gestures/MetaGestureEditor.cs
  10. +12 −0 Source/Assets/TouchScript/Editor/Gestures/MetaGestureEditor.cs.meta
  11. +7 −0 Source/Assets/TouchScript/Editor/Gestures/PressGestureEditor.cs
  12. +8 −1 Source/Assets/TouchScript/Editor/Gestures/ReleaseGestureEditor.cs
  13. +13 −0 Source/Assets/TouchScript/Editor/Gestures/TapGestureEditor.cs
  14. +23 −0 ...e/Assets/TouchScript/Editor/Gestures/TransformGestures/Base/OnePointTransformGestureBaseEditor.cs
  15. +2 −2 Source/Assets/TouchScript/Editor/Gestures/TransformGestures/Base/TransformGestureBaseEditor.cs
  16. +28 −0 ...e/Assets/TouchScript/Editor/Gestures/TransformGestures/Base/TwoPointTransformGestureBaseEditor.cs
  17. +19 −0 Source/Assets/TouchScript/Editor/Gestures/TransformGestures/PinnedTransformGestureEditor.cs
  18. +10 −1 Source/Assets/TouchScript/Editor/Gestures/TransformGestures/ScreenTransformGestureEditor.cs
  19. +20 −0 Source/Assets/TouchScript/Editor/Gestures/TransformGestures/TransformGestureEditor.cs
  20. +54 −8 Source/Assets/TouchScript/Editor/InputSources/StandardInputEditor.cs
  21. +7 −1 Source/Assets/TouchScript/Editor/Layers/FullscreenLayerEditor.cs
  22. +41 −14 Source/Assets/TouchScript/Editor/Layers/StandardLayerEditor.cs
  23. +70 −44 Source/Assets/TouchScript/Editor/TouchManagerEditor.cs
  24. +8 −4 Source/Assets/TouchScript/Examples/Camera/Camera.unity
  25. +175 −123 Source/Assets/TouchScript/Examples/Checkers/Checkers.unity
  26. +113 −80 Source/Assets/TouchScript/Examples/Colors/Colors.unity
  27. +31 −26 Source/Assets/TouchScript/Examples/Photos/Photos.unity
  28. +9 −8 Source/Assets/TouchScript/Examples/Portal/Portal.unity
  29. +9 −2 Source/Assets/TouchScript/Examples/Taps/Taps.unity
  30. +1 −4 Source/Assets/TouchScript/Scripts/Behaviors/Cursors/CursorManager.cs
  31. +3 −3 Source/Assets/TouchScript/Scripts/Behaviors/Transformer.cs
  32. +9 −0 Source/Assets/TouchScript/Scripts/Core.meta
  33. +1 −1 Source/Assets/TouchScript/Scripts/{ → Core}/DebuggableMonoBehaviour.cs
  34. 0 Source/Assets/TouchScript/Scripts/{ → Core}/DebuggableMonoBehaviour.cs.meta
  35. +1 −1 Source/Assets/TouchScript/Scripts/{ → Core}/GestureManagerInstance.cs
  36. 0 Source/Assets/TouchScript/Scripts/{ → Core}/GestureManagerInstance.cs.meta
  37. +1 −1 Source/Assets/TouchScript/Scripts/{ → Core}/LayerManagerInstance.cs
  38. 0 Source/Assets/TouchScript/Scripts/{ → Core}/LayerManagerInstance.cs.meta
  39. +2 −1 Source/Assets/TouchScript/Scripts/{ → Core}/TouchManagerInstance.cs
  40. 0 Source/Assets/TouchScript/Scripts/{ → Core}/TouchManagerInstance.cs.meta
  41. +1 −0 Source/Assets/TouchScript/Scripts/GestureManager.cs
  42. +6 −0 Source/Assets/TouchScript/Scripts/Gestures/FlickGesture.cs
  43. +13 −1 Source/Assets/TouchScript/Scripts/Gestures/Gesture.cs
  44. +6 −0 Source/Assets/TouchScript/Scripts/Gestures/LongPressGesture.cs
  45. +14 −4 Source/Assets/TouchScript/Scripts/Gestures/MetaGesture.cs
  46. +10 −0 Source/Assets/TouchScript/Scripts/Gestures/PressGesture.cs
  47. +14 −4 Source/Assets/TouchScript/Scripts/Gestures/ReleaseGesture.cs
  48. +6 −0 Source/Assets/TouchScript/Scripts/Gestures/TapGesture.cs
  49. +6 −0 Source/Assets/TouchScript/Scripts/Gestures/TransformGestures/PinnedTransformGesture.cs
  50. +7 −1 Source/Assets/TouchScript/Scripts/Gestures/TransformGestures/ScreenTransformGesture.cs
  51. +6 −0 Source/Assets/TouchScript/Scripts/Gestures/TransformGestures/TransformGesture.cs
  52. +10 −5 Source/Assets/TouchScript/Scripts/InputSources/InputSource.cs
  53. +18 −2 Source/Assets/TouchScript/Scripts/InputSources/StandardInput.cs
  54. +1 −0 Source/Assets/TouchScript/Scripts/LayerManager.cs
  55. +18 −2 Source/Assets/TouchScript/Scripts/Layers/StandardLayer.cs
  56. +1 −0 Source/Assets/TouchScript/Scripts/Pointers/Pointer.cs
  57. +17 −4 Source/Assets/TouchScript/Scripts/TouchManager.cs
@@ -0,0 +1,70 @@
/*
* @author Valentin Simonov / http://va.lent.in/
*/

using TouchScript.Behaviors.Cursors;
using UnityEditor;
using UnityEngine;
using TouchScript.Editor.EditorUI;

namespace TouchScript.Editor.Behaviors.Visualizer
{

[CustomEditor(typeof(CursorManager))]
internal sealed class CursorManagerEditor : UnityEditor.Editor
{

public static readonly GUIContent TEXT_DPI_HEADER = new GUIContent("Use DPI", "Scale touch pointer based on DPI.");
public static readonly GUIContent TEXT_CURSORS_HEADER = new GUIContent("Cursors", "Cursor prefabs used for different pointer types.");
public static readonly GUIContent TEXT_POINTER_SIZE = new GUIContent("Pointer size (cm)", "Pointer size in cm based on current DPI.");
public static readonly GUIContent TEXT_POINTER_PIXEL_SIZE = new GUIContent("Pointer size (px)", "Pointer size in pixels.");

private SerializedProperty mousePointerProxy, touchPointerProxy, penPointerProxy, objectPointerProxy;
private SerializedProperty useDPI, cursorSize, cursorPixelSize;
private SerializedProperty cursorsProps;

private void OnEnable()
{
mousePointerProxy = serializedObject.FindProperty("mouseCursor");
touchPointerProxy = serializedObject.FindProperty("touchCursor");
penPointerProxy = serializedObject.FindProperty("penCursor");
objectPointerProxy = serializedObject.FindProperty("objectCursor");

useDPI = serializedObject.FindProperty("useDPI");
cursorSize = serializedObject.FindProperty("cursorSize");
cursorPixelSize = serializedObject.FindProperty("cursorPixelSize");

cursorsProps = serializedObject.FindProperty("cursorsProps");
}

public override void OnInspectorGUI()
{
serializedObject.Update();

GUILayout.Space(5);

EditorGUILayout.PropertyField(useDPI, TEXT_DPI_HEADER);
if (useDPI.boolValue)
{
EditorGUILayout.PropertyField(cursorSize, TEXT_POINTER_SIZE);
}
else
{
EditorGUILayout.PropertyField(cursorPixelSize, TEXT_POINTER_PIXEL_SIZE);
}

var display = GUIElements.Header(TEXT_CURSORS_HEADER, cursorsProps);
if (display)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(mousePointerProxy, new GUIContent("Mouse Pointer Proxy"));
EditorGUILayout.PropertyField(touchPointerProxy, new GUIContent("Touch Pointer Proxy"));
EditorGUILayout.PropertyField(penPointerProxy, new GUIContent("Pen Pointer Proxy"));
EditorGUILayout.PropertyField(objectPointerProxy, new GUIContent("Object Pointer Proxy"));
EditorGUI.indentLevel--;
}

serializedObject.ApplyModifiedProperties();
}
}
}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -21,19 +21,16 @@ internal class TransformerEditor : UnityEditor.Editor
public static readonly GUIContent TEXT_ALLOW_CHANGING = new GUIContent("Allow Changing From Outside", "Indicates if this transform can be changed from another script.");
public static readonly GUIContent TEXT_SMOOTHING_FACTOR_DESC = new GUIContent("Indicates how much smoothing to apply. \n0 - no smoothing, 100000 - maximum.");

public static readonly GUIContent TEXT_HELP = new GUIContent("This component receives transform data from Transform Gestures and applies changes to the GameObject.");

private Transformer instance;

private SerializedProperty enableSmoothing, allowChangingFromOutside;
// private SerializedProperty smoothingFactor, positionThreshold, rotationThreshold, scaleThreshold;
private PropertyInfo enableSmoothing_prop;

protected virtual void OnEnable()
{
enableSmoothing = serializedObject.FindProperty("enableSmoothing");
// smoothingFactor = serializedObject.FindProperty("smoothingFactor");
// positionThreshold = serializedObject.FindProperty("positionThreshold");
// rotationThreshold = serializedObject.FindProperty("rotationThreshold");
// scaleThreshold = serializedObject.FindProperty("scaleThreshold");
allowChangingFromOutside = serializedObject.FindProperty("allowChangingFromOutside");

instance = target as Transformer;
@@ -67,6 +64,7 @@ public override void OnInspectorGUI()
}
EditorGUI.indentLevel--;
}
EditorGUILayout.LabelField(TEXT_HELP, GUIElements.HelpBox);

serializedObject.ApplyModifiedProperties();
}
@@ -17,6 +17,8 @@ internal static class GUIElements
public static GUIStyle HeaderStyle;
public static GUIStyle HeaderCheckbox;
public static GUIStyle HeaderFoldout;
public static GUIStyle SmallText;
public static GUIStyle SmallButton;

public static Texture2D PaneOptionsIcon;

@@ -53,6 +55,18 @@ static GUIElements()
HeaderCheckbox = new GUIStyle("ShurikenCheckMark");
HeaderFoldout = new GUIStyle("Foldout");

SmallText = new GUIStyle("miniLabel")
{
alignment = TextAnchor.UpperLeft,
};

SmallButton = new GUIStyle("Button")
{
fontSize = SmallText.fontSize,
fontStyle = SmallText.fontStyle,
font = SmallText.font,
};

if (EditorGUIUtility.isProSkin)
PaneOptionsIcon = (Texture2D)EditorGUIUtility.LoadRequired("Builtin Skins/DarkSkin/Images/pane options.png");
else
@@ -103,5 +117,15 @@ public static bool Header(GUIContent title, SerializedProperty expanded, Seriali

return display;
}

public static bool BasicHelpBox(GUIContent text)
{
EditorGUILayout.LabelField(text, HelpBox);
var rect = GUILayoutUtility.GetRect(10, 22, GUILayout.ExpandWidth(true));
rect.x = rect.width - 86;
rect.width = 100;
rect.height = 14;
return GUI.Button(rect, "Switch to Advanced", SmallButton);
}
}
}
@@ -16,7 +16,9 @@ internal sealed class FlickGestureEditor : GestureEditor
public static readonly GUIContent FLICK_TIME = new GUIContent("Flick Time (sec)", "Time interval in seconds during which pointers must move by <Minimum Distance> for the gesture to be recognized.");
public static readonly GUIContent MIN_DISTANCE = new GUIContent("Minimum Distance (cm)", "Minimum distance in cm pointers must move in <Flick Time> seconds for the gesture to be recognized.");

private SerializedProperty direction;
public static readonly GUIContent TEXT_HELP = new GUIContent("This component a fast flick gesture started over the GameObject. Switch to advanced view to see more options.");

private SerializedProperty direction;
private SerializedProperty flickTime;
private SerializedProperty minDistance;
private SerializedProperty movementThreshold;
@@ -31,22 +33,24 @@ protected override void OnEnable()
direction = serializedObject.FindProperty("direction");
}

public override void OnInspectorGUI()
{
#if UNITY_5_6_OR_NEWER
serializedObject.UpdateIfRequiredOrScript();
#else
serializedObject.UpdateIfDirtyOrScript();
#endif
protected override void drawBasic()
{
EditorGUILayout.PropertyField(direction, DIRECTION);
}

protected override void drawGeneral()
{
EditorGUIUtility.labelWidth = 180;
EditorGUILayout.PropertyField(direction, DIRECTION);
EditorGUILayout.PropertyField(movementThreshold, MOVEMENT_THRESHOLD);
EditorGUILayout.PropertyField(flickTime, FLICK_TIME);
EditorGUILayout.PropertyField(minDistance, MIN_DISTANCE);

serializedObject.ApplyModifiedProperties();
base.OnInspectorGUI();
}

protected override GUIContent getHelpText()
{
return TEXT_HELP;
}

}
}
@@ -37,6 +37,7 @@ internal class GestureEditor : UnityEditor.Editor

private Gesture instance;

private SerializedProperty basicEditor;
private SerializedProperty debugMode, friendlyGestures, requireGestureToFail,
minPointers, maxPointers,
useSendMessage, sendMessageTarget, sendStateChangeMessages,
@@ -56,6 +57,7 @@ protected virtual void OnEnable()
advancedProps = serializedObject.FindProperty("advancedProps");
limitsProps = serializedObject.FindProperty("limitsProps");
generalProps = serializedObject.FindProperty("generalProps");
basicEditor = serializedObject.FindProperty("basicEditor");

debugMode = serializedObject.FindProperty("debugMode");
friendlyGestures = serializedObject.FindProperty("friendlyGestures");
@@ -93,8 +95,6 @@ protected virtual void OnEnable()
EditorGUI.LabelField(rect, string.Format("{0} @ {1}", gesture.GetType().Name, gesture.name), GUIElements.BoxLabelStyle);
};
friendlyGesturesList.onRemoveCallback += list => { indexToRemove = list.index; };

if (debugMode != null) shouldDrawAdvanced = true;
}

public override void OnInspectorGUI()
@@ -108,73 +108,97 @@ public override void OnInspectorGUI()
GUILayout.Space(5);
bool display;

if (shouldDrawGeneral)
if (basicEditor.boolValue)
{
display = GUIElements.Header(TEXT_GENERAL_HEADER, generalProps);
if (display)
drawBasic();
if (GUIElements.BasicHelpBox(getHelpText()))
{
EditorGUI.indentLevel++;
drawGeneral();
EditorGUI.indentLevel--;
basicEditor.boolValue = false;
Repaint();
}
}

drawOtherGUI();

display = GUIElements.Header(TEXT_LIMITS_HEADER, limitsProps);
if (display)
else
{
EditorGUI.indentLevel++;
drawLimits();
EditorGUI.indentLevel--;
}
if (shouldDrawGeneral)
{
display = GUIElements.Header(TEXT_GENERAL_HEADER, generalProps);
if (display)
{
EditorGUI.indentLevel++;
drawGeneral();
EditorGUI.indentLevel--;
}
}

display = GUIElements.Header(TEXT_GESTURES_HEADER, friendlyGestures);
if (display)
{
EditorGUI.indentLevel++;
drawFriendlyGestures();
drawRequireToFail();
GUILayout.Space(5);
EditorGUI.indentLevel--;
}
drawOtherGUI();

display = GUIElements.Header(TEXT_USE_UNITY_EVENTS_HEADER, useUnityEvents, useUnityEvents, useUnityEvents_prop);
if (display)
{
EditorGUI.indentLevel++;
using (new EditorGUI.DisabledGroupScope(!useUnityEvents.boolValue))
display = GUIElements.Header(TEXT_LIMITS_HEADER, limitsProps);
if (display)
{
drawUnityEvents();
EditorGUI.indentLevel++;
drawLimits();
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}

display = GUIElements.Header(TEXT_USE_SEND_MESSAGE_HEADER, useSendMessage, useSendMessage, useSendMessage_prop);
if (display)
{
EditorGUI.indentLevel++;
using (new EditorGUI.DisabledGroupScope(!useSendMessage.boolValue))
display = GUIElements.Header(TEXT_GESTURES_HEADER, friendlyGestures);
if (display)
{
drawSendMessage();
EditorGUI.indentLevel++;
drawFriendlyGestures();
drawRequireToFail();
GUILayout.Space(5);
EditorGUI.indentLevel--;
}
EditorGUI.indentLevel--;
}

if (shouldDrawAdvanced)
{
display = GUIElements.Header(TEXT_ADVANCED_HEADER, advancedProps);
display = GUIElements.Header(TEXT_USE_UNITY_EVENTS_HEADER, useUnityEvents, useUnityEvents, useUnityEvents_prop);
if (display)
{
EditorGUI.indentLevel++;
drawAdvanced();
using (new EditorGUI.DisabledGroupScope(!useUnityEvents.boolValue))
{
drawUnityEvents();
}
EditorGUI.indentLevel--;
}

display = GUIElements.Header(TEXT_USE_SEND_MESSAGE_HEADER, useSendMessage, useSendMessage, useSendMessage_prop);
if (display)
{
EditorGUI.indentLevel++;
using (new EditorGUI.DisabledGroupScope(!useSendMessage.boolValue))
{
drawSendMessage();
}
EditorGUI.indentLevel--;
}

if (shouldDrawAdvanced)
{
display = GUIElements.Header(TEXT_ADVANCED_HEADER, advancedProps);
if (display)
{
EditorGUI.indentLevel++;
drawAdvanced();
EditorGUI.indentLevel--;
}
}

drawDebug();
}

serializedObject.ApplyModifiedProperties();
}

protected virtual void drawBasic()
{

}

protected virtual GUIContent getHelpText()
{
return new GUIContent("");
}

protected virtual void drawOtherGUI()
{

@@ -241,7 +265,6 @@ protected virtual void drawSendMessage()

protected virtual void drawAdvanced()
{
drawDebug();
}

protected virtual void drawDebug()
Oops, something went wrong.

0 comments on commit 8dd4339

Please sign in to comment.
You can’t perform that action at this time.