- Home /
Convert world to screenspace for screenshot of particular object
Is it possible to convert world to screenspace to screenshot a particular gameobject in the scene?
Say you have a bunch of objects in a scene. Users elects object A within full view of Camera, is it possible to convert this to screenspace to capture just that part of the image in a screenshot texture write (ReadPixels)?
Well, what do you mean? Do you want to get the coordinates of an object on the screen's 2D space? Or something else?
Do you mean "given an object's Bounds and a direction, how do I position a camera in that direction such that it views the whole bounds?"?
By this it seems to me you are saying you want a gameobject, lets say a flat plane in the world, doubling as a movie theater screen. That on lets say "activate" takes a screen shot of the world from your camera's perspective and saves it up onto the plane. Is this correct?
yes what Warwick said... say you have a bunch of objects in a scene. Users elects object A within full view of Camera, is it possible to convert this to screenspace to capture just that part of the image in a screenshot texture write?
The answer is a pile of trig that I'm too dumb to work out. In my current project, I generate icons something like small screenshots like this, but I just have hand-chosen rotation and distance for each class of item (I need to anyway, if I zoomed perfectly my shordsword and longsword would look the same!).
Answer by victorvijay · Jun 27, 2011 at 01:39 PM
you can get screen space to a ray and attachit to a object.
var ray: Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit: RaycastHit;
This looks like half a posting. Could you finish it or delete it?
Your answer
![](https://koobas.hobune.stream/wayback/20220612123030im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Scale Gameobject with defined size in pixels 2 Answers
Dragging panel(prefab) from screen space canvas to world space canvas and scaling to fit 0 Answers
See if an object is in a portion of the screen 1 Answer
World space and UI space 3 Answers
World BoxCollider size to Match Screen Space UI image size 1 Answer