| | 1 | | using DCL.Helpers; |
| | 2 | | using System.Collections; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace Tests |
| | 6 | | { |
| | 7 | | public class UITestsBase : IntegrationTestSuite_Legacy |
| | 8 | | { |
| | 9 | | protected override IEnumerator SetUp() |
| | 10 | | { |
| 30 | 11 | | yield return base.SetUp(); |
| 30 | 12 | | DCLCharacterController.i.PauseGravity(); |
| 30 | 13 | | TestHelpers.SetCharacterPosition(new Vector3(8f, 0f, 8f)); |
| 30 | 14 | | } |
| | 15 | |
|
| | 16 | | protected Vector2 CalculateAlignedAnchoredPosition(Rect parentRect, Rect elementRect, string vAlign = "center", |
| | 17 | | { |
| 16 | 18 | | Vector2 result = Vector2.zero; |
| | 19 | |
|
| | 20 | | switch (vAlign) |
| | 21 | | { |
| | 22 | | case "top": |
| 3 | 23 | | result.y = -elementRect.height / 2; |
| 3 | 24 | | break; |
| | 25 | | case "bottom": |
| 8 | 26 | | result.y = -(parentRect.height - elementRect.height / 2); |
| 8 | 27 | | break; |
| | 28 | | default: // center |
| 5 | 29 | | result.y = -parentRect.height / 2; |
| | 30 | | break; |
| | 31 | | } |
| | 32 | |
|
| | 33 | | switch (hAlign) |
| | 34 | | { |
| | 35 | | case "left": |
| 4 | 36 | | result.x = elementRect.width / 2; |
| 4 | 37 | | break; |
| | 38 | | case "right": |
| 7 | 39 | | result.x = (parentRect.width - elementRect.width / 2); |
| 7 | 40 | | break; |
| | 41 | | default: // center |
| 5 | 42 | | result.x = parentRect.width / 2; |
| | 43 | | break; |
| | 44 | | } |
| | 45 | |
|
| 16 | 46 | | return result; |
| | 47 | | } |
| | 48 | | } |
| | 49 | | } |