public override void OnUpdate()
 {
     GUIPainter.UpdatePainter(painterA);
     GUIPainter.UpdatePainter(painterB);
 }
        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;
                }
            }
        }