is there a way to generate a fake live image? of game

hello fellow devs does anyone know of a smart way or good way to generate a fake image of a game?

like from this screen

in a thumbnail format? possible 200x200 only

Use this to capture the current view. You will have to fiddle about to get it the resolution you are looking for. However, the docs report that this is removed from 2017.2.

ScreenCapture is the new API.

1 Like

Cheers!

i solved the problem i am now using RenderTexture and Texture2D to pre-generate a image of how the game look.

here’s the code that is responsible.

protected void GameSpawn()
    {
        for (int i = 0; i < GameManagerV2._Instance.Levels.Count; i++)
        {
            GameObject tempSlot = Instantiate(GameSlot); // Creates a object from the prefab GameSlot
            tempSlot.transform.SetParent(GameZone.transform, true); // Setting the parent of the Gameslot gameobject to be the GameZone, and we allow it's own transform and so to remain,
            tempSlot.name = GameManagerV2._Instance.Levels[i].objectName; // Changing the name of the GameSlot to whatever the Level is called

            GameObject tempTrigger = Instantiate(GameTrigger);
            tempTrigger.transform.SetParent(tempSlot.transform, false);
            tempTrigger.name = "Game_Trigger_" + i;

            GameObject tempGameSpawnZone = Instantiate(GameSpawnZone);
            tempGameSpawnZone.transform.SetParent(tempTrigger.transform, false);
            tempGameSpawnZone.name = "Game_Spawn_Zone_" + i;

            GameObject tempGameCapture = Instantiate(GameCapture);
            tempGameCapture.transform.SetParent(tempGameSpawnZone.transform, true);
            tempGameCapture.transform.position = new Vector3(tempGameCapture.transform.position.x, tempGameCapture.transform.position.y, -0.3f);

            RenderTexture rt = RenderTexture.GetTemporary(975, 575, 32); // Temporarily creates a texture of the defined size which we use later
            tempGameCapture.GetComponent<Camera>().targetTexture = rt; // setting the camera's render target to be the temporary texture
            tempGameCapture.GetComponent<Camera>().Render(); // manually rendering the texture that we have given it.

            RenderTexture saveActive = RenderTexture.active; // creating a varible for rendertexture to save for later uses as the currently active renderTexture
            RenderTexture.active = tempGameCapture.GetComponent<Camera>().targetTexture; // setting the currently active RenderTexture to the camera's target texture

            Texture2D texture = new Texture2D(tempGameCapture.GetComponent<Camera>().targetTexture.width, tempGameCapture.GetComponent<Camera>().targetTexture.height); // Creating a 2D texture based on what is inside the view of the camera
            texture.ReadPixels(new Rect(0, 0, tempGameCapture.GetComponent<Camera>().targetTexture.width, tempGameCapture.GetComponent<Camera>().targetTexture.height), 0, 0); // reading all pixels inside the camera's view based on its location
            texture.Apply(); // applying the texture so we can use it
            RenderTexture.active = saveActive; // setting the currently active Texture to the one the camera is seeing
            tempSlot.GetComponent<MeshRenderer>().materials[0].mainTexture = texture; // setting the texture of the GameSlot to the texture of what the camera just captured.

            Debug.Log(tempSlot.GetComponent<Renderer>().material.shader = Shader.Find("Unlit/Texture")); // changing the Material Shader to Until/Texture so we get the full image and not just a white/black background and we dont want any light to interfeer.

            RenderTexture.ReleaseTemporary(tempGameCapture.GetComponent<Camera>().targetTexture); // cleaning up the temporary Texture and removing it.
        }
    }