//---------------------------------------------------------------------------------------------
    //
    // Update area (UV and size) in widget
    //	it means widget's inTexPos and inTexSize will be modified
    //
    //---------------------------------------------------------------------------------------------
    static public void UpdateWidgetByArea(GUIBase_Widget widget, EditedArea editedArea, bool dirtyFlag)
    {
        if (widget)
        {
            Texture texture = widget.GetTexture();

            if (texture)
            {
                float width  = texture.width;
                float height = texture.height;

                widget.m_InTexPos.x = editedArea.Area.x / width;
                widget.m_InTexPos.y = editedArea.Area.y / height;

                widget.m_InTexSize.x = editedArea.Area.width / width;
                widget.m_InTexSize.y = editedArea.Area.height / height;

                widget.m_Grid9.Enabled     = editedArea.UsesGrid9;
                widget.m_Grid9.LeftSlice   = editedArea.Area.width != 0.0f ? editedArea.Slices.left / editedArea.Area.width  : 0.0f;
                widget.m_Grid9.TopSlice    = editedArea.Area.height != 0.0f ? editedArea.Slices.top / editedArea.Area.height : 0.0f;
                widget.m_Grid9.RightSlice  = editedArea.Area.width != 0.0f ? editedArea.Slices.right / editedArea.Area.width  : 0.0f;
                widget.m_Grid9.BottomSlice = editedArea.Area.height != 0.0f ? editedArea.Slices.bottom / editedArea.Area.height : 0.0f;

                if (dirtyFlag)
                {
                    EditorUtility.SetDirty(widget);
                }
            }
        }
    }
    //zkopiruje widget parametry do edit arey
    static public void CopyFromWidget(GUIBase_Widget selWidget, EditedArea targetArea)
    {
        if (selWidget)
        {
            Texture texture = selWidget.GetTexture();

            if (texture)
            {
                float width  = texture.width;
                float height = texture.height;

                targetArea.Area.x = selWidget.m_InTexPos.x * width;
                targetArea.Area.y = selWidget.m_InTexPos.y * height;

                targetArea.Area.width  = selWidget.m_InTexSize.x * width;
                targetArea.Area.height = selWidget.m_InTexSize.y * height;

                targetArea.UsesGrid9     = selWidget.m_Grid9.Enabled;
                targetArea.Slices.left   = Mathf.RoundToInt(selWidget.m_Grid9.LeftSlice * targetArea.Area.width);
                targetArea.Slices.top    = Mathf.RoundToInt(selWidget.m_Grid9.TopSlice * targetArea.Area.height);
                targetArea.Slices.right  = Mathf.RoundToInt(selWidget.m_Grid9.RightSlice * targetArea.Area.width);
                targetArea.Slices.bottom = Mathf.RoundToInt(selWidget.m_Grid9.BottomSlice * targetArea.Area.height);
            }
        }
    }
 public void CopyFrom(EditedArea other)
 {
     Area.x        = other.Area.x;
     Area.y        = other.Area.y;
     Area.width    = other.Area.width;
     Area.height   = other.Area.height;
     UsesGrid9     = other.UsesGrid9;
     Slices.left   = other.Slices.left;
     Slices.right  = other.Slices.right;
     Slices.top    = other.Slices.top;
     Slices.bottom = other.Slices.bottom;
 }