Created
October 20, 2019 19:23
-
-
Save sebolio/a51400ea9de7295911e4a48dfad39f30 to your computer and use it in GitHub Desktop.
Mover chat de uMMORPG para el medo en moviles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//by iamallama | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public partial class UIChat : MonoBehaviour | |
{ | |
void Start() | |
{ | |
RectTransform parentRT = GetComponent<RectTransform>(); | |
RectTransform panelRT = panel.GetComponent<RectTransform>(); | |
#if UNITY_IOS || UNITY_ANDROID | |
// adjust the anchor position relative to parent to be center | |
parentRT.anchorMin = new Vector2(0.5f, 0.5f); | |
parentRT.anchorMax = new Vector2(0.5f, 0.5f); | |
panelRT.anchorMin = new Vector2(0.5f, 0.5f); | |
panelRT.anchorMax = new Vector2(0.5f, 0.5f); | |
// reset the pivot to be center of element | |
parentRT.pivot = new Vector2(0.5f, 0.5f); | |
panelRT.pivot = new Vector2(0.5f, 0.5f); | |
// move to center of parent element | |
parentRT.anchoredPosition = Vector2.zero; | |
panelRT.anchoredPosition = Vector2.zero; | |
#else | |
// adjust the anchor position relative to parent to be bottom left | |
parentRT.anchorMin = Vector2.zero; | |
parentRT.anchorMax = Vector2.zero; | |
panelRT.anchorMin = Vector2.zero; | |
panelRT.anchorMax = Vector2.zero; | |
// reset the pivot to be bottom left | |
parentRT.pivot = Vector2.zero | |
panelRT.pivot = Vector2.zero; | |
// move bottom left of screen and up about 13px (the default position) | |
parentRT.anchoredPosition = Vector2.zero; | |
panelRT.anchoredPosition = new Vector2(0f, 13f); | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment