Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by M_Shazaib · Dec 15, 2018 at 03:59 PM · scripting problemgeneral

How to make the screenshot and share button not visible in the screen shot it self

I made a screen capture and share button for an AR app but I face a problem 1. I don't want the share button itself to be visible in the screenshot plz tell me what changes are to be made to do this I attached my script below

 using UnityEngine;
 using System.Collections;
 using System.Runtime.InteropServices;
 using System.IO;
 using System;
 
 /*
  * https://github.com/ChrisMaire/unity-native-sharing
  */
 
 public class Test : MonoBehaviour {
     public string ScreenshotName = "AR_FLAG.png";
 
     public void ShareScreenshotWithText(string text)
     {
         string screenShotPath = Application.persistentDataPath + "/" + ScreenshotName;
         if(File.Exists(screenShotPath)) File.Delete(screenShotPath);
 
         ScreenCapture.CaptureScreenshot(ScreenshotName);
 
         StartCoroutine(delayedShare(screenShotPath, text));
     }
 
     //CaptureScreenshot runs asynchronously, so you'll need to either capture the screenshot early and wait a fixed time
     //for it to save, or set a unique image name and check if the file has been created yet before sharing.
     IEnumerator delayedShare(string screenShotPath, string text)
     {
         while(!File.Exists(screenShotPath)) {
             yield return new WaitForSeconds(.0f);
         }
 
         NativeShare.Share(text, screenShotPath, "", "", "image/png", true, "");
     }
 
     //---------- Helper Variables ----------//
     private float width
     {
         get
         {
             return Screen.width;
         }
     }
 
     private float height
     {
         get
         {
             return Screen.height;
         }
     }
 
 
     //---------- Screenshot ----------//
     public void Screenshot()
     {
         // Short way
         StartCoroutine(GetScreenshot());
     }
 
     //---------- Get Screenshot ----------//
     public IEnumerator GetScreenshot()
     {
         yield return new WaitForEndOfFrame();
 
         // Get Screenshot
         Texture2D screenshot;
         screenshot = new Texture2D((int)width, (int)height, TextureFormat.ARGB32, false);
         screenshot.ReadPixels(new Rect(0, 0, width, height), 0, 0, false);
         screenshot.Apply();
 
         // Save Screenshot
         Save_Screenshot(screenshot);
     }
 
 
     //---------- Save Screenshot ----------//
     private void Save_Screenshot(Texture2D screenshot)
     {
         string screenShotPath = Application.persistentDataPath + "/" + DateTime.Now.ToString("dd-MM-yyyy_HH:mm:ss") + "_" + ScreenshotName;
         File.WriteAllBytes(screenShotPath, screenshot.EncodeToJPG());
 
         // Native Share
         StartCoroutine(DelayedShare_Image(screenShotPath));
     }
 
     //---------- Clear Saved Screenshots ----------//
     //public void Clear_SavedScreenShots()
    // {
         //string path = Application.persistentDataPath;
 
         //DirectoryInfo dir = new DirectoryInfo(path);
         //FileInfo[] info = dir.GetFiles("*.png");
 
         //foreach (FileInfo f in info)
        // {
             //File.Delete(f.FullName);
       //  }
    // }
 
     //---------- Delayed Share ----------//
     private IEnumerator DelayedShare_Image(string screenShotPath)
     {
         while (!File.Exists(screenShotPath))
         {
             yield return new WaitForSeconds(.05f);
         }
 
         // Share
         NativeShare_Image(screenShotPath);
     }
 
     //---------- Native Share ----------//
     private void NativeShare_Image(string screenShotPath)
    {
         string text = "Celebrate #Bahrain National Day with #AugmentedReality #Flag Point your own #ARflag and share with your friends #BahrainNationalDay #BahrainFlag #AR #BahrainFlagAR";
         string subject = "AR_FLAG";
        string url = "www.munfarid.org";
         string title = "Select Sharing app";
 
 #if UNITY_ANDROID
 
         subject = "AR_FLAG";
         text = "Celebrate #Bahrain National Day with #AugmentedReality #Flag Point your own #ARflag and share with your friends #BahrainNationalDay #BahrainFlag #AR #BahrainFlagAR";
 #endif
 
 #if UNITY_IOS
         subject = "Test subject.";
         text = "Test text";
 #endif
 
         // Share
         NativeShare.Share(text, screenShotPath, url, subject, "image/png", true, title);
     }
 }
 
 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

169 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do you make the material in the Terrain detail prototype properties update after runtime? 1 Answer

Move player according to the camera direction 1 Answer

Slide VS Touch 0 Answers

Particle System fails to emit() after last particle dies 3 Answers

Can't properly duplicate an enemy AI 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges