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 /
avatar image
0
Question by sketchers1 · Jan 02, 2012 at 04:26 AM · cameraguiimagecarinventory

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!

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
0

Answer by flamy · Jan 02, 2012 at 06:24 AM

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.

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 flamy · Jan 03, 2012 at 05:10 AM 0
Share

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

avatar image
0

Answer by KrisCadle · Feb 28, 2012 at 08:04 AM

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);
     texture.Apply();
 yield;

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

 while(!encoder.isDone)

     yield;

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

     Grab();

}

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() {

     if(!blankTexture){
         Debug.LogError("Assign a Texture in the inspector.");
         return;
  }

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

}

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 sketchers1 · Jul 23, 2012 at 09:05 PM 0
Share

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').

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

6 People are following this question.

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

Related Questions

My unity image isn't showing up, what gives? 0 Answers

How to change button image on click 2 Answers

Why does my sprite turn invisible for the camera 1 Answer

Remove Items and Item Tooltips 0 Answers

Display a gameObject like a GUITexture 2 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