/// <summary> /// Helper method for retrieving the correct signs for resizing and positioning /// based on pointer position relative to this handle. /// </summary> /// <param name="pData">The PointerEventData containing the pointers position.</param> /// <returns>A Vector4, with the following relations: /// x -> east <-> west resize sign /// y -> north <-> south resize sign /// z -> east <-> west re-position sign /// w -> north <-> south re-position sign.true /// </returns> private Vector4 GetSigns(PointerEventData pData) { Vector4 result = Vector4.zero; // Set of booleans representing whether the view data has reached // its minimum/maximum dimension on a given axis. bool isMinWidth = ViewData.TotalWidth == ViewData.MinTotalWidth; bool isMaxWidth = ViewData.TotalWidth == ViewData.MaxTotalWidth; bool isMinHeight = ViewData.TotalHeight == ViewData.MinTotalHeight; bool isMaxHeight = ViewData.TotalHeight == ViewData.MaxTotalHeight; if (pData.IsEastOf(transform.position)) { // x -> east <-> west resize sign. result.x = EastWestResizeSigns[ResizeDirection][0]; // z -> east <-> west re-position sign. result.z = EastWestPosSigns[ResizeDirection][0]; } else { // Same as above. result.x = EastWestResizeSigns[ResizeDirection][1]; result.z = EastWestPosSigns[ResizeDirection][1]; } if (pData.IsNorthOf(transform.position)) { // y -> north <-> south resize sign. result.y = NorthSouthResizeSigns[ResizeDirection][0]; // w -> north <-> south re-position sign. result.w = NorthSouthPosSigns[ResizeDirection][0]; } else { // Same as above. result.y = NorthSouthResizeSigns[ResizeDirection][1]; result.w = NorthSouthPosSigns[ResizeDirection][1]; } // If a dimension has reached its min/max, set the sign // for that dimension to zero. if (isMinWidth && result.x < 0) { result.x = 0; result.z = 0; } if (isMaxWidth && result.x > 0) { result.x = 0; result.z = 0; } if (isMinHeight && result.y < 0) { result.y = 0; result.w = 0; } if (isMaxHeight && result.y > 0) { result.y = 0; result.w = 0; } return(result); }