Ejemplo n.º 1
0
    static public void CapturedPositionByPanel(UIPanel targetPanel, ItemBoxPopup popup)
    {
        UIWidget popupWidget = popup.GetWidget();

        Vector3[] popupWidget_worldCorners = popupWidget.worldCorners;
        Vector3[] targetPanel_worldCorners = targetPanel.worldCorners;

        // right
        float value = popupWidget_worldCorners[3].x - targetPanel_worldCorners[3].x;

        if (value > 0)
        {
            Vector3 tempPos = popupWidget.transform.position;
            tempPos.x -= value;
            popupWidget.transform.position = tempPos;
        }

        // left
        value = popupWidget_worldCorners[0].x - targetPanel_worldCorners[0].x;
        if (value < 0)
        {
            Vector3 tempPos = popupWidget.transform.position;
            tempPos.x -= value;
            popupWidget.transform.position = tempPos;
        }

        // top
        value = popupWidget_worldCorners[1].y - targetPanel_worldCorners[1].y;
        if (value > 0)
        {
            Vector3 tempPos = popupWidget.transform.position;
            tempPos.y -= value;
            popupWidget.transform.position = tempPos;
        }

        // bottom
        value = popupWidget_worldCorners[0].y - targetPanel_worldCorners[0].y;
        if (value < 0)
        {
            Vector3 tempPos = popupWidget.transform.position;
            tempPos.y -= value;
            popupWidget.transform.position = tempPos;
        }
    }
Ejemplo n.º 2
0
    static public void CalcPopupPosition(UIPanel panel_popup, ItemBoxPopup popup, Reward_ItemBox itemBox)
    {
        UIWidget boxWidget    = itemBox.GetBoxWidget();
        Vector3  box_WorldPos = boxWidget.worldCenter;

        UIWidget popupBgSprite = popup.GetSpriteWidget();

        Vector3[] boxWidget_worldCorners     = boxWidget.worldCorners;
        Vector3[] popupBgSprite_worldCorners = popupBgSprite.worldCorners;

        float box_half_size_y   = (boxWidget_worldCorners[1].y - boxWidget_worldCorners[0].y) / 2;
        float popup_half_size_y = (popupBgSprite_worldCorners[1].y - popupBgSprite_worldCorners[0].y) / 2;

        // 아랫쪽에 생성
        Vector3 worldPos = itemBox.transform.position;

        if (box_WorldPos.y > UICamera.mainCamera.transform.position.y)
        {
            worldPos.y -= box_half_size_y;
            worldPos.y -= popup_half_size_y;
        }

        //popup.transform.position = worldPos;
        if (box_WorldPos.y <= UICamera.mainCamera.transform.position.y)
        {
            worldPos.y += box_half_size_y;
            worldPos.y += popup_half_size_y;
        }

        UIWidget tempWidget = popup.GetWidget();
        float    diff_y     = tempWidget.transform.position.y - popupBgSprite.transform.position.y;

        worldPos.y += diff_y;
        popup.SetPosition(worldPos);

        CapturedPositionByPanel(panel_popup, popup);
    }