Before updating to Windows 10 you may need to return your Pro license. More information here

Image inventory

So I want something kind of complicated. I hope this makes sense:

I have a car game where I want a button that says "TAKE PICTURE" When you click the GUI button, the game will take a picture of the current camera view. it will also make a click sound (which i have)

Below that, there will be a GUI button that says "Pictures".

When you click that, all of the images that you have taken will show up in 4 columns.

you can scroll up and down this and when you click on one of the pictures, it will expand. when you click it again, it will go back.

If you quit the game and reopen it, the images will still be there.

There should also be a button that allows you to delete an image when you expand it that says "Delete Current Image"

I know this is a lot. Sorry!

more ▼

asked Jan 02, 2012 at 04:26 AM

avatar image

241 57 58 66

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

first thing first getting a texture from the camera can be done with the help of Render texture in unity.

After getting the screen shot you can use EncodeToPng function to get the byte data... You can save it as it is into the disk or u can again convert it into string64 using this function. Either way you would have to use System.IO classes to save it to disk, I suggest using StreamWriter class... similarly u can use streamReader for retriving the image back...When you press delete you can delete the file previously created....!! Hope it helpy :)

For tumb nail of the texture in the GUI you can use Graphics.DrawTexture. For expanding the image you can use the same function.

more ▼

answered Jan 02, 2012 at 06:24 AM

avatar image

6.2k 32 43 82

then go for some video tutorials... Unity is damn easy to start with compared to most other engines :)

Jan 03, 2012 at 05:10 AM flamy
(comments are locked)
10|3000 characters needed characters left

This script lets you take screenshots and saves them next to your project, plus it draws a GUI texture of the last screenshot you took ;) Modify this for your own purpose. Add some animation and more GUI textures etc...

Put this on any object in your Hierarchy and drag any texture onto blankTexture. You can look at the "var url" in the inspector to see what file path is generated when you take a screenshot. This can be helpful for tweaking it...

private var count : int = 0; var blankTexture : Texture; var url = "";

function Update() { if(Input.GetKeyDown("s")) { ScreenshotEncode();



function ScreenshotEncode() {

 yield WaitForEndOfFrame();

     var texture:Texture2D = new Texture2D (Screen.width, Screen.height, TextureFormat.RGB24, false);
     texture.ReadPixels(Rect(0.0, 0.0, Screen.width, Screen.height), 0.0, 0.0);

     var encoder:JPGEncoder = new JPGEncoder(texture, 100.0);



     File.WriteAllBytes(Application.dataPath + "Overwrite" + count + ".jpg", encoder.GetBytes());



function Grab () {

     url = ("file:" + Application.dataPath + "Overwrite" + count + ".jpg");

     var www : WWW = new WWW (url);
     yield www;
     //you can also put this script on a cube and it will render the texture
     //renderer.material.mainTexture = www.texture;
     blankTexture = www.texture;
     count = count+1;

function OnGUI() {

         Debug.LogError("Assign a Texture in the inspector.");

     GUI.DrawTexture(Rect(10,200,360,260), blankTexture, ScaleMode.ScaleToFit, true, 1.0f);


more ▼

answered Feb 28, 2012 at 08:04 AM

avatar image

249 5 7 16

If I export the game, how can i get this to work on another computer, (Say if I sent a web version to my friend or something, would it still work on their computer?) And I am also getting this error:

Assets/Image Capture Script.js(21,21): BCE0018: The name 'JPGEncoder' does not denote a valid type ('not found').

Jul 23, 2012 at 09:05 PM sketchers1
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Jan 02, 2012 at 04:26 AM

Seen: 2029 times

Last Updated: Aug 10, 2012 at 03:19 PM