public void Update()
        {
            if (canDrawWindow)
            {
                /*
                 * if (showWindow)
                 *  GUIUtils.SetMouseScrolling(!windowRect.IsMouseInside());
                 * */
                updateTimer += TimeUtils.deltaTime;
                var mousePos = GUIUtils.MousePos;
                if (colorPickerSelected != null)
                {
                    GUIPainter.UpdatePainter(colorPickerSelected, () => { colorPickerSelected = null; });
                }

                if (dragTimer < .14f && dragTimer != 0f)
                {
                    dragTimer += TimeUtils.deltaTime;
                }
                cursorIsInsideTextureArea = windowRect.IsMouseInside();
                if (new Rect(windowRect.x + 5, windowRect.y + 30, windowRect.width - 285, windowRect.height - 80).IsMouseInside())
                {
                    if (Input.GetKey(KeyCode.LeftControl))
                    {
                        zoomFactor *= 1f + Input.mouseScrollDelta.y * 0.3f;
                    }

                    if (placingText)
                    {
                        if (Input.GetMouseButtonDown(0))
                        {
                            var field = parameters.AddField(fontManager.Arial, 0);
                            field.x       = (mousePos.x - windowRect.x - 5 + scrollTex.x) / zoomFactor;
                            field.y       = (mousePos.y - windowRect.y - 30 + scrollTex.y) / zoomFactor;
                            selectedField = field;
                            placingText   = false;
                            _justPlacedTextNowFocusField = true;
                        }
                    }
                    else if (placingRect)
                    {
                        if (placingRectFirstpoint != Vector2.down)
                        {
                            var field       = selectedField;
                            var secondPoint = new Vector2((mousePos.x - windowRect.x - 5 + scrollTex.x) / zoomFactor,
                                                          (mousePos.y - windowRect.y - 30 + scrollTex.y) / zoomFactor);
                            field.x        = Mathf.Min(placingRectFirstpoint.x, secondPoint.x);
                            field.y        = Mathf.Min(placingRectFirstpoint.y, secondPoint.y);
                            field.m_width  = (uint)Mathf.RoundToInt(Mathf.Abs(secondPoint.x - placingRectFirstpoint.x));
                            field.m_height = (uint)Mathf.RoundToInt(Mathf.Abs(secondPoint.y - placingRectFirstpoint.y));
                        }
                        if (Input.GetMouseButtonDown(0))
                        {
                            if (placingRectFirstpoint == Vector2.down)
                            {
                                ProceduralObjectsLogic.PlaySound();
                                var field = parameters.AddField(fontManager.Arial, 1);
                                placingRectFirstpoint = new Vector2((mousePos.x - windowRect.x - 5 + scrollTex.x) / zoomFactor,
                                                                    (mousePos.y - windowRect.y - 30 + scrollTex.y) / zoomFactor);
                                field.x       = placingRectFirstpoint.x;
                                field.y       = placingRectFirstpoint.y;
                                selectedField = field;
                            }
                            else
                            {
                                ProceduralObjectsLogic.PlaySound();
                                placingRectFirstpoint = Vector2.down;
                                placingRect           = false;
                            }
                        }
                    }
                    else
                    {
                        if (movingField > -1)
                        {
                            parameters[movingField].x = ((mousePos.x - windowRect.x - 5 + scrollTex.x) / zoomFactor) - dragTexPos.x;
                            parameters[movingField].y = ((mousePos.y - windowRect.y - 30 + scrollTex.y) / zoomFactor) - dragTexPos.y;
                            if (Input.GetMouseButtonDown(0))
                            {
                                ProceduralObjectsLogic.PlaySound();
                                dragTexPos  = Vector2.zero;
                                movingField = -1;
                            }
                        }
                        else if (movingField == -1)
                        {
                            if (Input.GetMouseButtonDown(0))
                            {
                                dragTimer = 0.0001f;
                            }
                            if (Input.GetMouseButton(0))
                            {
                                if (dragTimer >= .14f)
                                {
                                    if (dragTexPos == Vector2.zero)
                                    {
                                        dragTexPos = new Vector2((mousePos.x - windowRect.x - 5 + scrollTex.x) / zoomFactor, (mousePos.y - windowRect.y - 30 + scrollTex.y) / zoomFactor);
                                    }
                                }
                            }
                        }
                    }
                }

                if (Input.GetMouseButton(0))
                {
                    if (movingField == -2)
                    {
                        var size = mousePos - windowRect.position;
                        windowRect.size = new Vector2(Mathf.Max(windowRect.x + 400, size.x), Mathf.Max(windowRect.y + 350, size.y));
                    }
                    else if (movingField == -3)
                    {
                        separatorListEditionZone = Mathf.Clamp(mousePos.y - windowRect.y, 125, 450);
                    }
                    else if (dragTimer >= .14f)
                    {
                        if (dragTexPos != Vector2.zero)
                        {
                            scrollTex = new Vector2(zoomFactor * dragTexPos.x - mousePos.x + windowRect.x + 5, zoomFactor * dragTexPos.y - mousePos.y + windowRect.y + 30);
                        }
                    }
                }
                else if (Input.GetMouseButtonUp(0))
                {
                    if (movingField <= -2)
                    {
                        movingField = -1;
                    }

                    if (movingField <= -1)
                    {
                        dragTexPos = Vector2.zero;
                    }
                    dragTimer = 0f;
                }
                else
                {
                    if (movingField == -2)
                    {
                        movingField = -1;
                    }
                }
                if (updateTimer > .1f)
                {
                    if (TextParameters.IsDifference(parameters, parametersOld))
                    {
                        var oldTex = windowTex;
                        // apply changes
                        windowTex = parameters.ApplyParameters(originalTex);
                        editingObject.m_material.mainTexture = windowTex as Texture;
                        // save textparameters to the editingObject instance
                        editingObject.m_textParameters = parameters;
                        // try save on RAM usage
                        if (!TextParameters.IsEmpty(parametersOld))
                        {
                            oldTex.DisposeTexFromMemory();
                        }
                    }
                    parametersOld = TextParameters.Clone(parameters, false);
                    updateTimer   = 0f;
                }
            }
        }
        private void draw(int id)
        {
            GUI.DragWindow(new Rect(0, 0, windowRect.width - 52, 28));
            if (GUIUtils.CloseHelpButtons(windowRect, "Text_Customization"))
            {
                CloseWindow();
            }
            else
            {
                var scrollview = GUI.BeginScrollView(new Rect(5, 30, windowRect.width - 265, windowRect.height - 60), scrollTex, new Rect(0, 0, windowTex.width * zoomFactor, windowTex.height * zoomFactor));
                if (!Input.GetKey(KeyCode.LeftControl))
                {
                    scrollTex = scrollview;
                }
                GUI.DrawTexture(new Rect(0, 0, windowTex.width * zoomFactor, windowTex.height * zoomFactor), windowTex as Texture);

                if (movingField == -1)
                {
                    if (!placingRect && !placingText)
                    {
                        for (int i = 0; i < parameters.Count(); i++)
                        {
                            if (parameters[i].locked)
                            {
                                continue;
                            }
                            if (GUI.Button(new Rect(parameters[i].x * zoomFactor, parameters[i].y * zoomFactor, parameters[i].texWidth * zoomFactor, parameters[i].texHeight * zoomFactor), string.Empty, GUI.skin.label))
                            {
                                ProceduralObjectsLogic.PlaySound();
                                dragTexPos = new Vector2(((GUIUtils.MousePos.x - windowRect.x - 5 + scrollTex.x) / zoomFactor) - parameters[i].x,
                                                         ((GUIUtils.MousePos.y - windowRect.y - 30 + scrollTex.y) / zoomFactor) - parameters[i].y);
                                movingField = i;
                                placingText = false;
                                placingRect = false;
                            }
                        }
                    }
                }
                GUI.EndScrollView();

                // zoom
                if (GUI.RepeatButton(new Rect(5, windowRect.height - 29, 27, 25), "<size=20><b>+</b></size>"))
                {
                    zoomIn();
                }
                if (GUI.RepeatButton(new Rect(35, windowRect.height - 29, 27, 25), "<size=22><b>-</b></size>"))
                {
                    zoomOut();
                }
                GUI.Label(new Rect(67, windowRect.height - 28, 220, 27), LocalizationManager.instance.current["zoom"]);

                // parameters box
                GUI.Label(new Rect(windowRect.width - 255, 32, 260, 27), "<size=17>" + LocalizationManager.instance.current["text_fields"] + "</size>");

                // copy
                if (copiedField == null)
                {
                    GUI.Box(new Rect(windowRect.width - 35, 32, 25, 23), ProceduralObjectsMod.Icons[0]);
                }
                else
                {
                    if (GUI.Button(new Rect(windowRect.width - 35, 32, 25, 23), ProceduralObjectsMod.Icons[0]))
                    {
                        ProceduralObjectsLogic.PlaySound();
                        selectedField = parameters.AddField(TextField.Clone(copiedField, false));
                    }
                }
                if (parameters.Count() == 0)
                {
                    GUI.Box(new Rect(windowRect.width - 257, 60, 387, separatorListEditionZone - 60), string.Empty);
                }
                scrollParams = GUI.BeginScrollView(new Rect(windowRect.width - 256, 62, 254, separatorListEditionZone - 64), scrollParams, new Rect(0, 0, 235, parameters.Count() * 33 + 69));
                int j = 2;
                for (int i = 0; i < parameters.Count(); i++)
                {
                    var param = parameters[parameters.Count() - i - 1];
                    if (param.UIButton(new Vector2(0, j), this, movingField == -1))
                    {
                        if (selectedField == param)
                        {
                            selectedField = null;
                        }
                        else
                        {
                            selectedField = param;
                        }
                        placingRect           = false;
                        placingText           = false;
                        placingRectFirstpoint = Vector2.down;
                    }
                    j += 33;
                }
                if (GUI.Button(new Rect(3, j, 245, 30), "<b>+</b> " + LocalizationManager.instance.current["add_field"]))
                {
                    ProceduralObjectsLogic.PlaySound();
                    placingText           = true;
                    placingRect           = false;
                    placingRectFirstpoint = Vector2.down;
                    // selectedField = parameters.AddField(fontManager.Arial, 0);
                }
                if (GUI.Button(new Rect(3, j + 33, 245, 30), "<b>+</b> " + LocalizationManager.instance.current["add_color_rect"]))
                {
                    ProceduralObjectsLogic.PlaySound();
                    placingRect           = true;
                    placingText           = false;
                    placingRectFirstpoint = Vector2.down;
                    // selectedField = parameters.AddField(fontManager.Arial, 1);
                }
                GUI.EndScrollView();

                if (GUI.RepeatButton(new Rect(windowRect.width - 257, separatorListEditionZone - 1.5f, 387, 6), string.Empty))
                {
                    movingField = -3;
                }

                GUI.Box(new Rect(windowRect.width - 257, separatorListEditionZone + 5, 387, windowRect.height - separatorListEditionZone - 18), string.Empty);
                if (selectedField != null)
                {
                    selectedField.DrawUI(new Rect(windowRect.width - 255, separatorListEditionZone + 9, 245, windowRect.height - 290), this, ShowCharTable);
                    if (_justPlacedTextNowFocusField)
                    {
                        GUI.FocusControl("TextFieldPOTextCustom");
                        _justPlacedTextNowFocusField = false;
                    }
                }

                if (GUI.RepeatButton(new Rect(windowRect.width - 17, windowRect.height - 12, 16, 11), string.Empty))
                {
                    movingField = -2;
                }
            }
        }