Exemple #1
0
        public static PanelResizeWidth ResizeWidth(GameObject panel, float width, float padding, bool useRatio = false)
        {
            PanelResizeWidth panelResizeWidth = new PanelResizeWidth();
            Bounds           bounds           = ObjectBounds.ToWorld(panel);

            float oldScale = panel.transform.localScale.x;
            float oldWidth = bounds.size.x;
            float newWidth = width + padding * 2.15f;

            //if (panel.name == "SnapSpacingNumbersButton") Debug.Log("oldWidth=" + oldWidth + ",newWidth=" + newWidth + ",width=" + width + ",padding=" + padding);

            // oldWidth   newWidth
            // -------- = --------
            // oldScale   newScale
            if (useRatio)   // used for button resizing
            {
                panelResizeWidth.xScale = Ratio.SolveForD(oldWidth, oldScale, newWidth);
            }
            else
            {
                panelResizeWidth.xScale = newWidth;
            }
            panelResizeWidth.xOffset = (newWidth - oldWidth) / 2;

            return(panelResizeWidth);
        }
Exemple #2
0
        public static PanelResizeHeight ResizeHeight(GameObject panel, float height, float padding)
        {
            PanelResizeHeight panelResizeHeight = new PanelResizeHeight();
            Bounds            bounds            = ObjectBounds.ToWorld(panel);

            float oldHeight = bounds.size.y;
            float newHeight = height + padding * 2.15f;

            // oldWidth   newWidth
            // -------- = --------
            // oldScale   newScale
            panelResizeHeight.yScale  = newHeight;
            panelResizeHeight.yOffset = (newHeight - oldHeight) / 2;

            return(panelResizeHeight);
        }
Exemple #3
0
        private float TextMeshWidth()
        {
            Bounds textBounds = ObjectBounds.ToWorld(textMesh.gameObject);

            return(textBounds.size.x);
        }