• 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
1
Question by tenthplanet0 · Feb 04, 2013 at 12:16 PM · savedisplayscreenshotcapturescreenshotloadassetatpath

capturing screen shot, and showing the captured image on screen

Hiii everyone, I have the requirement of capturing screen shot, saving it and accessing to show it on screen. How can I do this? please help out this new bee.... Thanks in advance

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

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Unity_gamer · Feb 04, 2013 at 01:04 PM

Hi,

You can use "Application.CaptureScreenshot" to capture Image in Unity. you can refer the below link for reference. http://docs.unity3d.com/Documentation/ScriptReference/Application.CaptureScreenshot.html

 public static string screenshotFilename = "screenshotName.png";
 
 void Start() {
     Application.CaptureScreenshot( screenshotName );
 }
 
 //use this to  find the Path of the Image
 
 var pathToImage = Application.persistentDataPath + "/" + screenshotName;

Try this out and post the result here.

Thanks

Comment
Add comment · Show 9 · 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
avatar image tenthplanet0 · Feb 04, 2013 at 01:22 PM 0
Share

Hi, Here you go with my problem exactly 1. I am capturing screen shot by Application.CaptureScreenshot("path"+screenshot1.png); 2. Now need to fetch captured screen shot instantly & i am doing this by curSnap = Resources.Load("screenshot1"); I am getting null in curSnap if I access that screenshot instant but I am able to fetch once I close the engine & restart it.

$$anonymous$$y requirement is to get that captured snap as soon as I save in hard disk.

I am just bit to acheive that. Pls help me out Thanks

avatar image Unity_gamer · Feb 04, 2013 at 02:06 PM 0
Share

u tried using "Application.persistentDataPath" ? use this link for reference. http://docs.unity3d.com/Documentation/ScriptReference/Application-persistentDataPath.html

avatar image robertbu · Feb 04, 2013 at 04:34 PM 0
Share

To load an image back in use the WWW class. If you are trying to speed up that process, just don't yield. It's a bit ugly but:

         Application.CaptureScreenshot ("e:/foo.png");
         WWW www = new WWW("file://e:/foo.png"); 
         while (!www.isDone)
             ;
         www.LoadImageIntoTexture((Texture2D)renderer.material.mainTexture);

You can save the image anywhere you have permission. If your target platform is controlled in some way, do as @Unity_gamer suggests and use persistentDataPath.

avatar image Unity_gamer · Feb 05, 2013 at 06:46 AM 0
Share

@robertbu Thanks for correcting me ..:) I used this in ios implementation , and it worked fine for me.

avatar image tenthplanet0 · Feb 25, 2013 at 05:19 PM 0
Share

Thanks developers. I found the alternate solution using "WWWForm". Thanks for your care and help

Show more comments
avatar image
0

Answer by Aqibsadiq · Apr 12, 2016 at 04:35 AM

@tenthplanet0 Here is simple Code for capturing screen shot, and showing the captured image on screen

This Code is For Andriod and IPhone.For PC Just Give the Image Path

 public RawImage image;
 void Start()
 {
       Photo();
       Invoke("GetPhoto",1f);
 }
 
 public void Photo()
     {
         Application.CaptureScreenshot(Variables.ImageName);
     }
 
 public void GetPhoto()
     {    
         #if !UNITY_EDITOR
         string url = Application.persistentDataPath +"/"+Variables.ImageName;
         var bytes = File.ReadAllBytes( url );
         Texture2D texture = new Texture2D( 73, 73 );
         texture.LoadImage( bytes );
         image.texture= texture ;
         #endif
     }

Comment
Add comment · Show 1 · 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
avatar image fonko · Sep 29, 2018 at 02:56 AM 0
Share

what is Variables.ImageName?

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

13 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

Related Questions

How to save a screenshot to the camera roll (picture gallery)? 3 Answers

Save and Display Best Score 2 Answers

How to take screen shot or save screen? 0 Answers

how can i take a screenshot (by UiButton) and save it in CameraRoll (Gallery in iOS)? 0 Answers

[Solved] Take a Screenshot from game and use it immediately in UI 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges