I need some help with a screenshot, please

Hey guys…

I am trying to mix two different things, to see if they work, but I can’t realize on how to do that…

Here is the thing:

I have a plugin (U3DXT) to share a screenshot taken from an IOS device into Facebook or Twitter… now, that plugin shows a way to capture this screenshot:

var image = new Texture2D (Screen.width, Screen.height, TextureFormat.RGB24, false);
                        image.ReadPixels (new Rect (0, 0, Screen.width, Screen.height), 0, 0, false);
                        image.Apply ();

This way, however, takes the SS with no texts, so, it does not work for me, since I want to share the final score the user makes.

So, checking on Unity docs and some other answers, I found this way to take the screenshot and use it:

Application.CaptureScreenshot("screenShotToShare.png");
WWW www = new WWW(Application.persistentDataPath + "/screenShotToShare.png");
            while (!www.isDone);
            www.LoadImageIntoTexture((Texture2D)renderer.material.mainTexture);

Now, what I actually need is to “combine” that var image to be this mainTexture, since the code, to share the SS into Face would be:

SocialXT.Post (SLRequest.SLServiceTypeFacebook, "Can you beat my score?", image, true);

Is it clear?

Any help, please?

Thanks to google, if you read the docs you find this

tldr: wait for end of frame before taking your SS

    bool takeSS;
    public Texture2D ss;

    void OnGUI () {
        if ( GUILayout.Button( "Take ss" ) ) {
            takeSS = true;
        }
    }

    void OnPostRender () {
        if ( takeSS ) {
            StartCoroutine( take() );
            takeSS = false;
        }
    }

    IEnumerator take () {
        yield return new WaitForEndOfFrame();
        ss = new Texture2D( Screen.width, Screen.height );
        ss.ReadPixels( new Rect( 0, 0, Screen.width, Screen.height ), 0, 0 );
        ss.Apply();
    }

If Im understanding right your first method doesnt have your UI in it ? Have you tried doing ReadPixels in LateUpdate ?

Edit: John beat me to it.