Example #1
0
        public void SetViewportParams(int2 scroll, float zoom)
        {
            // PERF: Calling SetViewportParams on each renderer is slow. Only call it when things change.
            var resolutionChanged = lastResolution != Resolution;

            if (resolutionChanged)
            {
                lastResolution = Resolution;
                RgbaSpriteRenderer.SetViewportParams(Resolution, 0f, 0f, 1f, int2.Zero);
                SpriteRenderer.SetViewportParams(Resolution, 0f, 0f, 1f, int2.Zero);
                RgbaColorRenderer.SetViewportParams(Resolution, 0f, 0f, 1f, int2.Zero);
            }

            // If zoom evaluates as different due to floating point weirdness that's OK, setting the parameters again is harmless.
            if (resolutionChanged || lastScroll != scroll || lastZoom != zoom)
            {
                lastScroll = scroll;
                lastZoom   = zoom;
                WorldRgbaSpriteRenderer.SetViewportParams(Resolution, depthScale, depthOffset, zoom, scroll);
                WorldSpriteRenderer.SetViewportParams(Resolution, depthScale, depthOffset, zoom, scroll);
                WorldVoxelRenderer.SetViewportParams(Resolution, zoom, scroll);
                WorldRgbaColorRenderer.SetViewportParams(Resolution, depthScale, depthOffset, zoom, scroll);
            }
        }
Example #2
0
        public void SetViewportParams(int2 scroll, float zoom)
        {
            var resolutionChanged = lastResolution != Resolution;

            if (resolutionChanged)
            {
                lastResolution = Resolution;
                RgbaSpriteRenderer.SetViewportParams(Resolution, 1f, int2.Zero);
                SpriteRenderer.SetViewportParams(Resolution, 1f, int2.Zero);
                LineRenderer.SetViewportParams(Resolution, 1f, int2.Zero);
            }

            // If zoom evaluates as different due to floating point weirdness that's OK, setting the parameters again is harmless.
            if (resolutionChanged || lastScroll != scroll || lastZoom != zoom)
            {
                lastScroll = scroll;
                lastZoom   = zoom;
                WorldRgbaSpriteRenderer.SetViewportParams(Resolution, zoom, scroll);
                WorldSpriteRenderer.SetViewportParams(Resolution, zoom, scroll);
                WorldVoxelRenderer.SetViewportParams(Resolution, zoom, scroll);
                WorldLineRenderer.SetViewportParams(Resolution, zoom, scroll);
                WorldQuadRenderer.SetViewportParams(Resolution, zoom, scroll);
            }
        }