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); }
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); }
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); } } }
public static void SetRectToAnchorSelectedGameObject_Shortcut() { GameObject[] selectedGameObjects = Selection.gameObjects; foreach (var g in selectedGameObjects) { RectTransform rectTransform = g.GetComponent <RectTransform>(); if (rectTransform != null) { Undo.RecordObject(rectTransform, "Set Anchors"); AiryUIAnchors.SetRectToAnchor(rectTransform); } } }
private void SetAnchorsBottomRight() { if (GUILayout.Button("Set Anchors Bottom Right", buttonContentStyle)) { GameObject[] selectedGameObjects = Selection.gameObjects; foreach (var g in selectedGameObjects) { RectTransform rectTransform = g.GetComponent <RectTransform>(); if (rectTransform != null) { AiryUIAnchors.SetAnchorsBottomRight(rectTransform); } } } }
private void SetAnchorsCenterOfRect() { if (GUILayout.Button("Set Anchors To Center Of Rect", buttonContentStyle)) { GameObject[] selectedGameObjects = Selection.gameObjects; foreach (var g in selectedGameObjects) { RectTransform rectTransform = g.GetComponent <RectTransform>(); if (rectTransform != null) { Undo.RecordObject(rectTransform, "Set Anchors"); AiryUIAnchors.SetAnchorsCenterOfRect(rectTransform); } } } }
private void SetRectToAnchorSelectedGameObject() { if (GUILayout.Button("Align Rect To Anchors\nCtrl+Shift+W", buttonContentStyle)) { GameObject[] selectedGameObjects = Selection.gameObjects; foreach (var g in selectedGameObjects) { RectTransform rectTransform = g.GetComponent <RectTransform>(); if (rectTransform != null) { AiryUIAnchors.SetRectToAnchor(rectTransform); } } } GUILayout.Space(5); }
private void SetAnchorsBottomRight() { var btnContent = new GUIContent() { text = "Set Anchors Bottom Right", tooltip = "Move Anchors to bottom right of 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.SetAnchorsBottomRight(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(); } }
private static void SetRectToAnchorSelectedGameObject() { var btnContent = new GUIContent() { text = "Align Rect To Anchors\nCtrl+Shift+W", tooltip = "Align The Rect's borders With The Anchors" }; 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.SetRectToAnchor(rectTransform); } } } GUILayout.Space(5); }