Skip to content

Commit a3fe273

Browse files
committed
TouchManager.ShouldCreateStandardInput property specifying if StandardInput should be created if no inputs found.
1 parent 155a753 commit a3fe273

4 files changed

Lines changed: 30 additions & 7 deletions

File tree

Source/Assets/TouchScript/Editor/TouchManagerEditor.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,23 @@ internal sealed class TouchManagerEditor : UnityEditor.Editor
1818
{
1919
private static readonly GUIContent DISPLAY_DEVICE = new GUIContent("Display Device", "Display device properties where such parameters as target DPI are stored.");
2020
private static readonly GUIContent CREATE_CAMERA_LAYER = new GUIContent("Create Camera Layer", "Indicates if TouchScript should create a CameraLayer for you if no layers present in a scene. This is usually a desired behavior but sometimes you would want to turn this off if you are using TouchScript only to get touch input from some device.");
21+
private static readonly GUIContent CREATE_STANDARD_INPUT = new GUIContent("Create Standard Input", "");
2122
private static readonly GUIContent USE_SEND_MESSAGE = new GUIContent("Use SendMessage", "If you use UnityScript or prefer using Unity Messages you can turn them on with this option.");
2223
private static readonly GUIContent SEND_MESSAGE_TARGET = new GUIContent("SendMessage Target", "The GameObject target of Unity Messages. If null, host GameObject is used.");
2324
private static readonly GUIContent SEND_MESSAGE_EVENTS = new GUIContent("SendMessage Events", "Which events should be sent as Unity Messages.");
2425
private static readonly GUIContent LAYERS_HEADER = new GUIContent("Touch Layers", "Sorted array of Touch Layers in the scene.");
2526

2627
private TouchManager instance;
2728
private ReorderableList layersList;
28-
private SerializedProperty layers, displayDevice, shouldCreateCameraLayer, useSendMessage, sendMessageTarget, sendMessageEvents;
29+
private SerializedProperty layers, displayDevice, shouldCreateCameraLayer, shouldCreateStandardInput, useSendMessage, sendMessageTarget, sendMessageEvents;
2930

3031
private void OnEnable()
3132
{
3233
instance = target as TouchManager;
3334
layers = serializedObject.FindProperty("layers");
3435
displayDevice = serializedObject.FindProperty("displayDevice");
3536
shouldCreateCameraLayer = serializedObject.FindProperty("shouldCreateCameraLayer");
37+
shouldCreateStandardInput = serializedObject.FindProperty("shouldCreateStandardInput");
3638
useSendMessage = serializedObject.FindProperty("useSendMessage");
3739
sendMessageTarget = serializedObject.FindProperty("sendMessageTarget");
3840
sendMessageEvents = serializedObject.FindProperty("sendMessageEvents");
@@ -74,6 +76,7 @@ public override void OnInspectorGUI()
7476

7577
if (Application.isPlaying) GUI.enabled = false;
7678
EditorGUILayout.PropertyField(shouldCreateCameraLayer, CREATE_CAMERA_LAYER);
79+
EditorGUILayout.PropertyField(shouldCreateStandardInput, CREATE_STANDARD_INPUT);
7780
GUI.enabled = true;
7881

7982
EditorGUIUtility.labelWidth = 160;

Source/Assets/TouchScript/Scripts/ITouchManager.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public interface ITouchManager
8686
/// </summary>
8787
/// <value><c>true</c> if a CameraLayer should be created on startup; otherwise, <c>false</c>.</value>
8888
/// <remarks>This is usually a desired behavior but sometimes you would want to turn this off if you are using TouchScript only to get touch input from some device.</remarks>
89-
Boolean ShouldCreateCameraLayer { get; set; }
89+
bool ShouldCreateCameraLayer { get; set; }
90+
91+
bool ShouldCreateStandardInput { get; set; }
9092

9193
/// <summary>
9294
/// Gets the list of touch layers.
@@ -178,7 +180,6 @@ public interface ITouchManager
178180
/// </summary>
179181
/// <param name="id">Touch id to cancel.</param>
180182
void CancelTouch(int id);
181-
182183
}
183184

184185
/// <summary>
@@ -197,7 +198,9 @@ public class TouchEventArgs : EventArgs
197198
/// <summary>
198199
/// Initializes a new instance of the <see cref="TouchEventArgs"/> class.
199200
/// </summary>
200-
private TouchEventArgs() {}
201+
private TouchEventArgs()
202+
{
203+
}
201204

202205
/// <summary>
203206
/// Returns cached instance of EventArgs.

Source/Assets/TouchScript/Scripts/TouchManager.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ public bool ShouldCreateCameraLayer
181181
set { shouldCreateCameraLayer = value; }
182182
}
183183

184+
public bool ShouldCreateStandardInput
185+
{
186+
get { return shouldCreateStandardInput; }
187+
set { shouldCreateStandardInput = value; }
188+
}
189+
184190
/// <summary>
185191
/// Gets or sets a value indicating whether Unity messages are sent when <see cref="ITouchManager"/> dispatches events.
186192
/// </summary>
@@ -246,7 +252,9 @@ public static bool IsInvalidPosition(Vector2 position)
246252

247253
[SerializeField] private Object displayDevice;
248254

249-
[SerializeField] [ToggleLeft] private Boolean shouldCreateCameraLayer = true;
255+
[SerializeField] [ToggleLeft] private bool shouldCreateCameraLayer = true;
256+
257+
[SerializeField] [ToggleLeft] private bool shouldCreateStandardInput = true;
250258

251259
[SerializeField] [ToggleLeft] private bool useSendMessage = false;
252260

@@ -267,6 +275,7 @@ private void Awake()
267275

268276
Instance.DisplayDevice = displayDevice as IDisplayDevice;
269277
Instance.ShouldCreateCameraLayer = ShouldCreateCameraLayer;
278+
Instance.ShouldCreateStandardInput = ShouldCreateStandardInput;
270279
for (var i = 0; i < layers.Count; i++)
271280
{
272281
Instance.AddLayer(layers[i], i);
@@ -358,4 +367,4 @@ private void frameFinishedHandler(object sender, EventArgs e)
358367

359368
#endregion
360369
}
361-
}
370+
}

Source/Assets/TouchScript/Scripts/TouchManagerInstance.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ public bool ShouldCreateCameraLayer
142142
set { shouldCreateCameraLayer = value; }
143143
}
144144

145+
/// <inheritdoc />
146+
public bool ShouldCreateStandardInput
147+
{
148+
get { return shouldCreateStandardInput; }
149+
set { shouldCreateStandardInput = value; }
150+
}
151+
145152
/// <inheritdoc />
146153
public IList<TouchLayer> Layers
147154
{
@@ -172,7 +179,8 @@ public IList<ITouch> ActiveTouches
172179

173180
private static bool shuttingDown = false;
174181
private static TouchManagerInstance instance;
175-
private Boolean shouldCreateCameraLayer = true;
182+
private bool shouldCreateCameraLayer = true;
183+
private bool shouldCreateStandardInput = true;
176184

177185
private IDisplayDevice displayDevice;
178186
private float dpi = 96;

0 commit comments

Comments
 (0)