Example #1
0
        /** Causes the control to redraw it's contents to the render texture */
        protected void repaintRenderTexture()
        {
            // We can only repaint cache during an onGui 'repaint' event.
            if (!SmartUI.isRepaint)
            {
                return;
            }

            validateRenderTexture();

            Engine.PerformanceStatsInProgress.GuiRenderTextureRepaints++;

            var previousRenderTexture = RenderTexture.active;

            RenderTexture.active = compositeRenderTexture;

            GL.Clear(true, true, new Color(0f, 0f, 0f, 0f));

            int oldX = X;
            int oldY = Y;

            X = 0;
            Y = 0;

            // unity scale to readjust opengl transformation matrix.
            SmartUI.Scale(Engine.GuiScale);
            forceStandardDraw = true;
            base.Draw();
            forceStandardDraw = false;
            SmartUI.Scale(1f / Engine.GuiScale);

            X = oldX;
            Y = oldY;

            RenderTexture.active = previousRenderTexture;

            dirtyRenderTexture = false;
            lastRepaint        = Time.time;
        }