public BorderParamContainer GetParams(Vector2 size, Data.Enum.Border type) { var topRightPos = _camera.ScreenToWorldPoint(size); BorderParamContainer parameters; switch (type) { case Data.Enum.Border.Left: var leftPos = _camera.ScreenToWorldPoint(Vector3.zero); parameters = new BorderParamContainer { Size = new Vector2(1.0f, topRightPos.y * 2.0f), Offset = new Vector2(leftPos.x - 0.5f, 0.0f) }; break; case Data.Enum.Border.Right: parameters = new BorderParamContainer { Size = new Vector2(1.0f, topRightPos.y * 2.0f), Offset = new Vector2(topRightPos.x + 0.5f, 0.0f) }; break; case Data.Enum.Border.Top: parameters = new BorderParamContainer { Size = new Vector2(topRightPos.x * 2.0f, 1.0f), Offset = new Vector2(0.0f, topRightPos.y + 0.5f) }; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } return(parameters); }
public void SetParams(BorderParamContainer parameters, Data.Enum.Border type) { switch (type) { case Data.Enum.Border.Left: _left.offset = parameters.Offset; _left.size = parameters.Size; break; case Data.Enum.Border.Right: _right.offset = parameters.Offset; _right.size = parameters.Size; break; case Data.Enum.Border.Top: _top.offset = parameters.Offset; _top.size = parameters.Size; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } }