private CocoVCSAnchor GetTouchPoint(Vector2 pos) { // x CocoVCSAlignX alignX = CocoVCSAlignX.None; pos.x /= Screen.width; if (pos.x <= _detectBounds.x) { alignX = CocoVCSAlignX.Left; } else if (pos.x >= 1 - _detectBounds.x) { alignX = CocoVCSAlignX.Right; } else if (Mathf.Abs(pos.x - 0.5f) <= _detectBounds.x / 2) { alignX = CocoVCSAlignX.Center; } // y CocoVCSAlignY alignY = CocoVCSAlignY.None; pos.y /= Screen.height; if (pos.y >= 1 - _detectBounds.y) { alignY = CocoVCSAlignY.Upper; } else if (pos.y <= _detectBounds.y) { alignY = CocoVCSAlignY.Lower; } else if (Mathf.Abs(pos.y - 0.5f) < _detectBounds.y / 2) { alignY = CocoVCSAlignY.Middle; } CocoVCSAnchor anchor = GetAnchor(alignX, alignY); //Debug.Log ("GetTouchPoint: " + pos + " -> " + anchor); return(anchor); }
private void InitDisplayAnchor() { _displayRect.size = _displayStyle.CalcSize(_displayContent) + new Vector2(4, 0); CocoVCSAlignX alignX = GetAlignX(_displayAnchor); switch (alignX) { case CocoVCSAlignX.Center: _displayRect.x = (Screen.width - _displayRect.width) / 2; break; case CocoVCSAlignX.Right: _displayRect.x = Screen.width - _displayRect.width; break; default: _displayRect.x = 0; break; } CocoVCSAlignY alignY = GetAlignY(_displayAnchor); switch (alignY) { case CocoVCSAlignY.Middle: _displayRect.y = (Screen.height - _displayRect.height) / 2; break; case CocoVCSAlignY.Lower: _displayRect.y = Screen.height - _displayRect.height; break; default: _displayRect.y = 0; break; } }
private CocoVCSAnchor GetAnchor(CocoVCSAlignX alignX, CocoVCSAlignY alignY) { return((CocoVCSAnchor)((int)alignX | (int)alignY)); }