Example #1
0
    void Locate(UIWidget widget, int left, int top, UIWidget parent)
    {
        SetPositionAndSize posAndSize = widget.GetComponent <SetPositionAndSize> ();

        if (posAndSize == null)
        {
            posAndSize = widget.gameObject.AddComponent <SetPositionAndSize> ();
        }
        posAndSize.transform.parent = parent.transform;

        SetPositionAndSize setPosAndSize = posAndSize.GetComponent <SetPositionAndSize> ();

        setPosAndSize.localLeft = left;
        setPosAndSize.localTop  = top;
        setPosAndSize.LocateAndResize();
        posAndSize.transform.localScale = Vector3.one;
    }
Example #2
0
    void ComputeSize()
    {
        SetPositionAndSize posAndSize = GetComponent <SetPositionAndSize> ();
        int width = 0, height = 0;

        UIWidget[] widgets = GetComponentsInChildren <UIWidget> ();
        foreach (UIWidget widget in widgets)
        {
            if (widget.transform != transform)
            {
                width  = (int)Mathf.Max(width, widget.localSize.x + widget.transform.localPosition.x);
                height = (int)Mathf.Max(height, -widget.transform.localPosition.y + widget.localSize.y);
            }
        }

        posAndSize.pixelWidth  = width;
        posAndSize.pixelHeight = height;
    }