private void SetAnchorsToFitRect() { if (GUILayout.Button("Align Anchors With Rect\nCtrl+Shift+Q", buttonContentStyle)) { GameObject[] selectedGameObjects = Selection.gameObjects; foreach (var g in selectedGameObjects) { RectTransform rectTransform = g.GetComponent <RectTransform>(); if (rectTransform != null) { Undo.RecordObject(rectTransform, "Set Anchors"); AiryUIAnchors.SetAnchorsToRect(rectTransform); } } } GUILayout.Label("Note: You may need to click twice to fit the anchors if the pivot is not centered", new GUIStyle() { alignment = TextAnchor.MiddleCenter, wordWrap = true }); GUILayout.Space(20); }
private static void SetAnchorsToFitRect() { var btnContent = new GUIContent() { text = "Align Anchors With Rect\nCtrl+Shift+Q", tooltip = "Move Anchors to be aligned with the rect" }; if (GUILayout.Button(btnContent, GUILayout.Height(50))) { GameObject[] selectedGameObjects = Selection.gameObjects; foreach (var g in selectedGameObjects) { RectTransform rectTransform = g.GetComponent <RectTransform>(); if (rectTransform != null) { AiryUIAnchors.SetAnchorsToRect(rectTransform); } } } GUILayout.Label("Note: You may need to click twice to fit the anchors if the pivot is not centered", new GUIStyle() { alignment = TextAnchor.MiddleCenter, wordWrap = true }); GUILayout.Space(20); }
public static void SetAnchorsToFitRect_Shortcut() { GameObject[] selectedGameObjects = Selection.gameObjects; foreach (var g in selectedGameObjects) { RectTransform rectTransform = g.GetComponent <RectTransform>(); if (rectTransform != null) { AiryUIAnchors.SetAnchorsToRect(rectTransform); } } }
private IEnumerator InstantiateBackButton() { // Instantiate Button and make it child of this game object if (backButton == null) { yield return(new WaitForSeconds(showDelay)); backButton = Instantiate(backButtonPrefab, transform, false); backButton.onClick.AddListener(DoBackOnThisObject); backButton.name = backButtonPrefab.name; backBtnAnimatedElement = backButton.GetComponent <AiryUIAnimatedElement>(); backBtnAnimatedElement.OnShowComplete.AddListener(() => AiryUIAnchors.SetAnchorsToRect(backBtnAnimatedElement.GetComponent <RectTransform>())); img = backButton.transform.Find("Image").GetComponent <Image>(); txt = backButton.transform.Find("Text").GetComponent <Text>(); SetGraphics(); SetPositionAndScale(); backBtnAnimatedElement.ShowElement(); } }