public void Create()
 {
     if (CamerasMgr.Camera2RTCommon == null)
     {
         base.set_enabled(false);
         return;
     }
     if (RTSyncBackground.RTCanvas == null)
     {
         RTSyncBackground.RTCanvas = new GameObject("RTCanvas");
         RTSyncBackground.RTCanvas.get_transform().set_parent(CamerasMgr.Camera2RTCommon.get_transform());
         RTSyncBackground.RTCanvas.get_transform().set_localPosition(Vector3.get_zero());
         RTSyncBackground.RTCanvas.get_transform().set_localRotation(Quaternion.get_identity());
         RTSyncBackground.RTCanvas.get_transform().set_localScale(Vector3.get_one());
         RTSyncBackground.RTCanvas.set_layer(LayerSystem.NameToLayer("FX"));
         Canvas canvas = RTSyncBackground.RTCanvas.AddComponent <Canvas>();
         canvas.set_renderMode(1);
         canvas.set_pixelPerfect(false);
         canvas.set_worldCamera(CamerasMgr.Camera2RTCommon);
         CanvasScaler canvasScaler = RTSyncBackground.RTCanvas.AddComponent <CanvasScaler>();
         canvasScaler.set_uiScaleMode(0);
     }
     if (this.m_goSync != null)
     {
         this.m_goSync.SetActive(true);
         this.SyncImage();
     }
     else
     {
         this.m_goSync = new GameObject(base.get_gameObject().get_name());
         this.m_goSync.get_transform().set_parent(RTSyncBackground.RTCanvas.get_transform());
         this.m_goSync.get_transform().set_localPosition(Vector3.get_zero());
         this.m_goSync.get_transform().set_localRotation(Quaternion.get_identity());
         this.m_goSync.get_transform().set_localScale(Vector3.get_one());
         this.m_goSync.set_layer(LayerSystem.NameToLayer("FX"));
         this.m_thisImage = base.get_gameObject().GetComponent <Image>();
         if (this.m_thisImage != null)
         {
             this.m_syncImage = this.m_goSync.AddComponent <Image>();
             this.m_syncImage.set_material(RTSyncBackground.BackgroundMat);
         }
         else
         {
             this.m_thisRawImage = base.get_gameObject().GetComponent <RawImage>();
             if (this.m_thisRawImage != null)
             {
                 this.m_syncRawImage = this.m_goSync.AddComponent <RawImage>();
                 this.m_syncRawImage.set_material(RTSyncBackground.BackgroundMat);
             }
         }
         this.SyncImage();
         if (base.get_gameObject().GetComponent <UIMaskLayer>() != null)
         {
             this.m_goSync.AddComponent <UIMaskLayer>();
         }
     }
 }
    public static void MakeSnapshot(FreezeFrame freezeFrame)
    {
        GameObject gameObject = GameObject.Find("MainCanvas");

        if (gameObject == null)
        {
            Debug.LogError("Could not find MainCanvas, did you rename it?");
            return;
        }
        GameObject gameObject2 = new GameObject(freezeFrame.get_name() + "_SnaphotCamera");

        gameObject2.get_transform().SetParent(null, false);
        gameObject2.get_transform().Translate(0f, 0f, -1f);
        Camera        camera        = gameObject2.AddComponent <Camera>();
        RenderTexture renderTexture = new RenderTexture(320, 320, 24);
        Material      material      = new Material(Shader.Find("UI/Unlit/Transparent"));

        material.SetTexture("_MainTex", renderTexture);
        camera.set_orthographic(true);
        camera.set_orthographicSize(100f);
        camera.set_targetTexture(renderTexture);
        camera.set_depth(-1f);
        camera.set_clearFlags(2);
        camera.set_backgroundColor(new Color(0f, 0f, 0f, 1f));
        GameObject gameObject3 = new GameObject(freezeFrame.get_name() + "_DarkRoomCanvas");
        Canvas     canvas      = gameObject3.AddComponent <Canvas>();

        canvas.set_planeDistance(500f);
        canvas.set_renderMode(1);
        canvas.set_worldCamera(camera);
        CanvasScaler canvasScaler = gameObject3.AddComponent <CanvasScaler>();

        canvasScaler.set_uiScaleMode(1);
        canvasScaler.set_referenceResolution(new Vector2(1200f, 900f));
        canvasScaler.set_matchWidthOrHeight(1f);
        GameObject gameObject4 = new GameObject(freezeFrame.get_name() + "_Snapshot");

        gameObject4.get_transform().SetParent(gameObject.get_transform(), false);
        Image image = gameObject4.AddComponent <Image>();

        gameObject4.GetComponent <RectTransform>().set_sizeDelta(new Vector2(320f, 320f));
        image.set_material(material);
        freezeFrame.get_transform().SetParent(gameObject3.get_transform(), false);
        camera.Render();
    }