screenshot and share on social

hi guys, i’m trying to create a screenshot to share then on social networks. the script I use works, only the button I use to take the photo and share it also appears in the screenshot … what I would like is not to display the button in the screenshot, how can I do?

i’m using the plugin NativeShare

the script is this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;

public class ShareButton : MonoBehaviour {

    public void clickShare() {
        StartCoroutine(TakeSSAndShare());
    }

    private IEnumerator TakeSSAndShare() {
        yield return new WaitForEndOfFrame();

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

        string filePath = Path.Combine( Application.temporaryCachePath, "shared img.png" );
        File.WriteAllBytes( filePath, ss.EncodeToPNG() );
       
        // To avoid memory leaks
        Destroy( ss );

        new NativeShare().AddFile( filePath ).SetSubject( "Subject goes here" ).SetText( "Hello world!" ).Share();
    }
}

Make a new camera and copy the settings from your camera and set the Culling Mask so that you ignore the UI etc. in that screen capture camera.

Here’s a discussion on the topic: