Example #1
0
        private void Update()
        {
            SuperController sc = SuperController.singleton;

            switch (state)
            {
            case READY:
            {
                // enable cameras as needed
                bool active = sc.hiResScreenshotPreview.gameObject.activeSelf;
                screenshotCamera.enabled = false;
                previewCamera.enabled    = active;
                if (!active)
                {
                    return;
                }

                // ensure RenderTexture size
                if (screenshotTexture == null || screenshotTexture.width != resolutionWidth[resolutionIdx])
                {
                    if (screenshotTexture != null)
                    {
                        screenshotTexture.Release();
                        Destroy(screenshotTexture);
                    }
                    RenderTextureDescriptor descriptor = previewCamera.targetTexture.descriptor;
                    descriptor.width  = resolutionWidth[resolutionIdx];
                    descriptor.height = resolutionHeight[resolutionIdx];
                    screenshotTexture = new RenderTexture(descriptor);
                    screenshotTexture.Create();
                }

                // check for user input
                if (!sc.GetRightSelect() && !sc.GetLeftSelect() && !sc.GetMouseSelect())
                {
                    return;
                }

                // init screenshot sequence
                screenshotCamera.targetTexture = screenshotTexture;
                screenshotCamera.enabled       = true;
                state = SCREENSHOT;
                break;
            }

            case SCREENSHOT:
            {
                // fake user input to cause SuperController.ProcessHiResScreenshot do run
                sc.SetLeftSelect();
                state = CLEANUP;
                break;
            }

            case CLEANUP:
            {
                // cleanup
                screenshotCamera.targetTexture = null;
                screenshotCamera.enabled       = false;
                state = READY;
                break;
            }
            }
        }