Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
  • Help Room /
avatar image
0
Question by Siggytron · Oct 04, 2020 at 05:17 PM · androidtransparencycapturecapturescreenshotscreencapture

Screencapture.screenshot image is faint or translucent (Android)

Hello,

I followed this tutorial on taking a screenshot using Unity's Screencapture.Capturescreenshot() method. https://www.youtube.com/watch?v=DQeylS0l4S4&t=92s

It seemed pretty straight-forward and easy to follow. However, on display, the screenshot image (a basic cube in 3D space) appears translucent. Does anyone have any idea why and how I can fix it so it shows a true screen shot? I used another phone to take a picture of my actual screen when I'm taking the screen shot here (Sorry it's a little blurry. The cube moves):Actual screen

... And then what it looks like on display here (Notice how you can see through it) ...:alt text

Here is the code for the screen capture script:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class TakeScreenshot : MonoBehaviour {
 
     public void TakeAShot()
     {
         StartCoroutine ("CaptureIt");
     }
 
     IEnumerator CaptureIt()
     {
         string timeStamp = System.DateTime.Now.ToString("dd-MM-yyyy-HH-mm-ss");
         string fileName = "Screenshot" + timeStamp + ".png";
         string pathToSave = fileName;
         ScreenCapture.CaptureScreenshot(pathToSave);
         yield return new WaitForEndOfFrame();
     }
 
 }

And here is the code for displaying. It converts the .png file to a texture, makes a sprite out of the texture, and displays the sprite on the canvas.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using System.IO;
 
 public class ScreenshotPreview : MonoBehaviour {
     
     public GameObject canvas;
     string[] files = null;
     int whichScreenShotIsShown= 0;
 
     // Use this for initialization
     void Start () {
         files = Directory.GetFiles(Application.persistentDataPath + "/", "*.png");
         if (files.Length > 0) {
             GetPictureAndShowIt ();
         }
     }
 
     void GetPictureAndShowIt()
     {
         string pathToFile = files [whichScreenShotIsShown];
         Texture2D texture = GetScreenshotImage (pathToFile);
         Sprite sp = Sprite.Create (texture, new Rect (0, 0, texture.width, texture.height),
             new Vector2 (0.5f, 0.5f));
         canvas.GetComponent<Image> ().sprite = sp;
     }
 
     Texture2D GetScreenshotImage(string filePath)
     {
         Texture2D texture = null;
         byte[] fileBytes;
         if (File.Exists (filePath)) {
             fileBytes = File.ReadAllBytes (filePath);
             texture = new Texture2D (2, 2, TextureFormat.RGB24, false);
             texture.LoadImage (fileBytes);
         }
         return texture;
     }
 }

It all works fine in the tutorial. I am using Android. Thank you in advance for your constructive ideas.

img-20201004-125301228.jpg (249.8 kB)
img-20201004-125229548.jpg (132.6 kB)
Comment
Add comment · Show 1
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
avatar image Siggytron · Oct 04, 2020 at 08:42 PM 0
Share

Additional information:

So my thinking was that the problem had to either be in the capturing or the displaying. I realized I could look at the saved .png file in my Android files to see what they looked like before they are pulled back into the app for display.

The result? : The .png looks perfect. So it's just a problem with the displaying. I still haven't solved the whole problem but now I know the screen is being captured perfectly with Unity's Screencapture.Capturescreenshot method.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Siggytron · Oct 06, 2020 at 03:26 PM

It turns out that the 'alpha' value for my panel in the second scene was at about 50%, which in alpha values is about 127. To display the image exactly as it was taken on the screen, alpha needs to be at 255 , which represent 0% transparency. In general, many people want UI elements to have a degree of transparency so that you can see the main scene behind the UI elements. However, for viewing the screenshot I wanted no transparency. Therefore => Select the Panel in your hierarchy. Go to the Color quality in the Inspector. Double-click. Then set the Alpha value to 255.

If you have a situation where you do not have a dedicated scene just for viewing your screenshot, you can change the alpha value using a script. In my case I could set my alpha to 255 permanently because the only purpose for that scene was to display screenshots.

Alpha Setting for Panel element


panelalphatransparency.png (157.7 kB)
Comment
Add comment · Share
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

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

370 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 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 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

Android: SVG Support 1 Answer

Capturing 360 Panorama in android 0 Answers

How to Capture pixels from monitor display? (C# similar to print-screen in windows but only for a rect). 0 Answers

How does one prevent their Android Build from being transparent? 0 Answers

gameview capture in realtime 1 Answer


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