Skip to content
Permalink
Browse files

Added some UNITY_5_6_OR_NEWER defines to work in 5.5.

  • Loading branch information...
valyard committed Aug 1, 2017
1 parent 891b1a1 commit 6ae7a00461f1172294e5cec22507256f29874d78
@@ -133,17 +133,20 @@ public uint CursorPixelSize
private ObjectPool<PointerCursor> objectPool;
private Dictionary<int, PointerCursor> cursors = new Dictionary<int, PointerCursor>(10);

#if UNITY_5_6_OR_NEWER
private CustomSampler cursorSampler;
#endif

#endregion

#region Unity methods

private void Awake()
{
#if UNITY_5_6_OR_NEWER
cursorSampler = CustomSampler.Create("[TouchScript] Update Cursors");

cursorSampler.Begin();
#endif

mousePool = new ObjectPool<PointerCursor>(2, instantiateMouseProxy, null, clearProxy);
touchPool = new ObjectPool<PointerCursor>(10, instantiateTouchProxy, null, clearProxy);
@@ -159,7 +162,9 @@ private void Awake()
enabled = false;
}

#if UNITY_5_6_OR_NEWER
cursorSampler.End();
#endif
}

private void OnEnable()
@@ -228,7 +233,9 @@ private void updateCursorSize()

private void pointersAddedHandler(object sender, PointerEventArgs e)
{
#if UNITY_5_6_OR_NEWER
cursorSampler.Begin();
#endif

updateCursorSize();

@@ -263,12 +270,16 @@ private void pointersAddedHandler(object sender, PointerEventArgs e)
cursors.Add(pointer.Id, cursor);
}

#if UNITY_5_6_OR_NEWER
cursorSampler.End();
#endif
}

private void pointersRemovedHandler(object sender, PointerEventArgs e)
{
#if UNITY_5_6_OR_NEWER
cursorSampler.Begin();
#endif

var count = e.Pointers.Count;
for (var i = 0; i < count; i++)
@@ -295,12 +306,16 @@ private void pointersRemovedHandler(object sender, PointerEventArgs e)
}
}

#if UNITY_5_6_OR_NEWER
cursorSampler.End();
#endif
}

private void pointersPressedHandler(object sender, PointerEventArgs e)
{
#if UNITY_5_6_OR_NEWER
cursorSampler.Begin();
#endif

var count = e.Pointers.Count;
for (var i = 0; i < count; i++)
@@ -311,12 +326,16 @@ private void pointersPressedHandler(object sender, PointerEventArgs e)
cursor.SetState(pointer, PointerCursor.CursorState.Pressed);
}

#if UNITY_5_6_OR_NEWER
cursorSampler.End();
#endif
}

private void PointersUpdatedHandler(object sender, PointerEventArgs e)
{
#if UNITY_5_6_OR_NEWER
cursorSampler.Begin();
#endif

var count = e.Pointers.Count;
for (var i = 0; i < count; i++)
@@ -327,12 +346,16 @@ private void PointersUpdatedHandler(object sender, PointerEventArgs e)
cursor.UpdatePointer(pointer);
}

#if UNITY_5_6_OR_NEWER
cursorSampler.End();
#endif
}

private void pointersReleasedHandler(object sender, PointerEventArgs e)
{
#if UNITY_5_6_OR_NEWER
cursorSampler.Begin();
#endif

var count = e.Pointers.Count;
for (var i = 0; i < count; i++)
@@ -343,7 +366,9 @@ private void pointersReleasedHandler(object sender, PointerEventArgs e)
cursor.SetState(pointer, PointerCursor.CursorState.Released);
}

#if UNITY_5_6_OR_NEWER
cursorSampler.End();
#endif
}

private void pointersCancelledHandler(object sender, PointerEventArgs e)
@@ -59,7 +59,9 @@ public static IGestureManager Instance
private List<Gesture> gesturesToReset = new List<Gesture>(20);
private Dictionary<int, List<Gesture>> pointerToGestures = new Dictionary<int, List<Gesture>>(10);

#if UNITY_5_6_OR_NEWER
private CustomSampler gestureSampler;
#endif

#endregion

@@ -111,7 +113,9 @@ private void Awake()
pointerListPool.WarmUp(20);
transformListPool.WarmUp(1);

#if UNITY_5_6_OR_NEWER
gestureSampler = CustomSampler.Create("[TouchScript] Update Gestures");
#endif
}

private void OnEnable()
@@ -224,7 +228,9 @@ internal Gesture.GestureState INTERNAL_GestureChangeState(Gesture gesture, Gestu

private void updatePressed(IList<Pointer> pointers)
{
#if UNITY_5_6_OR_NEWER
gestureSampler.Begin();
#endif

var activeTargets = transformListPool.Get();
var gesturesInHierarchy = gestureListPool.Get();
@@ -376,12 +382,16 @@ private void updatePressed(IList<Pointer> pointers)
activeGesturesThisUpdate.Clear();
pointersToDispatchForGesture.Clear();

#if UNITY_5_6_OR_NEWER
gestureSampler.End();
#endif
}

private void updateUpdated(IList<Pointer> pointers)
{
#if UNITY_5_6_OR_NEWER
gestureSampler.Begin();
#endif

sortPointersForActiveGestures(pointers);

@@ -400,12 +410,16 @@ private void updateUpdated(IList<Pointer> pointers)
activeGesturesThisUpdate.Clear();
pointersToDispatchForGesture.Clear();

#if UNITY_5_6_OR_NEWER
gestureSampler.End();
#endif
}

private void updateReleased(IList<Pointer> pointers)
{
#if UNITY_5_6_OR_NEWER
gestureSampler.Begin();
#endif

sortPointersForActiveGestures(pointers);

@@ -425,12 +439,16 @@ private void updateReleased(IList<Pointer> pointers)
activeGesturesThisUpdate.Clear();
pointersToDispatchForGesture.Clear();

#if UNITY_5_6_OR_NEWER
gestureSampler.End();
#endif
}

private void updateCancelled(IList<Pointer> pointers)
{
#if UNITY_5_6_OR_NEWER
gestureSampler.Begin();
#endif

sortPointersForActiveGestures(pointers);

@@ -450,7 +468,9 @@ private void updateCancelled(IList<Pointer> pointers)
activeGesturesThisUpdate.Clear();
pointersToDispatchForGesture.Clear();

#if UNITY_5_6_OR_NEWER
gestureSampler.End();
#endif
}

private void sortPointersForActiveGestures(IList<Pointer> pointers)
@@ -264,7 +264,9 @@ public IList<Pointer> PressedPointers
private IPointerLogger pLogger;
#endif

#if UNITY_5_6_OR_NEWER
private CustomSampler samplerUpdateInputs, samplerUpdateAdded, samplerUpdatePressed, samplerUpdateUpdated, samplerUpdateReleased, samplerUpdateRemoved, samplerUpdateCancelled;
#endif

#endregion

@@ -535,13 +537,15 @@ private void Awake()
_layerRemovePointer = layerRemovePointer;
_layerCancelPointer = layerCancelPointer;

#if UNITY_5_6_OR_NEWER
samplerUpdateInputs = CustomSampler.Create("[TouchScript] Update Inputs");
samplerUpdateAdded = CustomSampler.Create("[TouchScript] Added Pointers");
samplerUpdatePressed = CustomSampler.Create("[TouchScript] Press Pointers");
samplerUpdateUpdated = CustomSampler.Create("[TouchScript] Update Pointers");
samplerUpdateReleased = CustomSampler.Create("[TouchScript] Release Pointers");
samplerUpdateRemoved = CustomSampler.Create("[TouchScript] Remove Pointers");
samplerUpdateCancelled = CustomSampler.Create("[TouchScript] Cancel Pointers");
#endif
}

#if UNITY_5_4_OR_NEWER
@@ -625,14 +629,20 @@ private void createInput()

private void updateInputs()
{
#if UNITY_5_6_OR_NEWER
samplerUpdateInputs.Begin();
#endif
for (var i = 0; i < inputCount; i++) inputs[i].UpdateInput();
#if UNITY_5_6_OR_NEWER
samplerUpdateInputs.End();
#endif
}

private void updateAdded(List<Pointer> pointers)
{
#if UNITY_5_6_OR_NEWER
samplerUpdateAdded.Begin();
#endif

var addedCount = pointers.Count;
var list = pointerListPool.Get();
@@ -660,7 +670,9 @@ private void updateAdded(List<Pointer> pointers)
pointersAddedInvoker.InvokeHandleExceptions(this, PointerEventArgs.GetCachedEventArgs(list));
pointerListPool.Release(list);

#if UNITY_5_6_OR_NEWER
samplerUpdateAdded.End();
#endif
}

private bool layerAddPointer(TouchLayer layer)
@@ -671,7 +683,9 @@ private bool layerAddPointer(TouchLayer layer)

private void updateUpdated(List<int> pointers)
{
#if UNITY_5_6_OR_NEWER
samplerUpdateUpdated.Begin();
#endif

var updatedCount = pointers.Count;
var list = pointerListPool.Get();
@@ -712,7 +726,9 @@ private void updateUpdated(List<int> pointers)
pointersUpdatedInvoker.InvokeHandleExceptions(this, PointerEventArgs.GetCachedEventArgs(list));
pointerListPool.Release(list);

#if UNITY_5_6_OR_NEWER
samplerUpdateUpdated.End();
#endif
}

private bool layerUpdatePointer(TouchLayer layer)
@@ -723,7 +739,9 @@ private bool layerUpdatePointer(TouchLayer layer)

private void updatePressed(List<int> pointers)
{
#if UNITY_5_6_OR_NEWER
samplerUpdatePressed.Begin();
#endif

var pressedCount = pointers.Count;
var list = pointerListPool.Get();
@@ -752,9 +770,6 @@ private void updatePressed(List<int> pointers)

#if TOUCHSCRIPT_DEBUG
pLogger.Log(pointer, PointerEvent.Pressed);
#endif

#if TOUCHSCRIPT_DEBUG
if (DebugMode) addDebugFigureForPointer(pointer);
#endif
}
@@ -763,12 +778,16 @@ private void updatePressed(List<int> pointers)
pointersPressedInvoker.InvokeHandleExceptions(this, PointerEventArgs.GetCachedEventArgs(list));
pointerListPool.Release(list);

#if UNITY_5_6_OR_NEWER
samplerUpdatePressed.End();
#endif
}

private void updateReleased(List<int> pointers)
{
#if UNITY_5_6_OR_NEWER
samplerUpdateReleased.Begin();
#endif

var releasedCount = pointers.Count;
var list = pointerListPool.Get();
@@ -809,12 +828,16 @@ private void updateReleased(List<int> pointers)
}
pointerListPool.Release(list);

#if UNITY_5_6_OR_NEWER
samplerUpdateReleased.End();
#endif
}

private void updateRemoved(List<int> pointers)
{
#if UNITY_5_6_OR_NEWER
samplerUpdateRemoved.Begin();
#endif

var removedCount = pointers.Count;
var list = pointerListPool.Get();
@@ -858,7 +881,9 @@ private void updateRemoved(List<int> pointers)
}
pointerListPool.Release(list);

#if UNITY_5_6_OR_NEWER
samplerUpdateRemoved.End();
#endif
}

private bool layerRemovePointer(TouchLayer layer)
@@ -869,7 +894,9 @@ private bool layerRemovePointer(TouchLayer layer)

private void updateCancelled(List<int> pointers)
{
#if UNITY_5_6_OR_NEWER
samplerUpdateCancelled.Begin();
#endif

var cancelledCount = pointers.Count;
var list = pointerListPool.Get();
@@ -914,7 +941,9 @@ private void updateCancelled(List<int> pointers)
}
pointerListPool.Release(list);

#if UNITY_5_6_OR_NEWER
samplerUpdateCancelled.End();
#endif
}

private bool layerCancelPointer(TouchLayer layer)
@@ -103,7 +103,9 @@ private void updateNativeResulotion()
break;
// Probably TVs
case RuntimePlatform.SamsungTVPlayer:
#if UNITY_5_6_OR_NEWER
case RuntimePlatform.Switch:
#endif
case RuntimePlatform.WiiU:
case RuntimePlatform.XboxOne:
case RuntimePlatform.tvOS:
@@ -198,7 +200,9 @@ private void updateNativeDPI()
break;
// Probably TVs
case RuntimePlatform.SamsungTVPlayer:
#if UNITY_5_6_OR_NEWER
case RuntimePlatform.Switch:
#endif
case RuntimePlatform.WiiU:
case RuntimePlatform.XboxOne:
case RuntimePlatform.tvOS:
Oops, something went wrong.

0 comments on commit 6ae7a00

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