|
I come from a background of coding flash applications for many years and I'm finding it hard to do things that were previously very simple with 2d pixel based space in Unity. I was hoping for some input on how one would go about doing them in 3d. The lack of width and height relative to the screen is the main thing I am struggling to come to terms with. For example, in flash I could make an object fill the screen by simply doing:
Or I could center an object by doing:-
I have worked out that localeScale and localePosition can be used for some things. If someone could post how they would commonly perform these tasks in Unity, along with any other examples, it would help me a lot. Thanks
(comments are locked)
|
|
I use something like this to achieve what you are trying to do: public Camera cam; ... Now, if your object has a scale of (1, 1, 1) by default you can just use viewWidth and viewHeight to adjust it's scale to fill the screen. obj.transform.localScale = new Vector3(viewWidth, viewHeight, 1); Hope that helps.
(comments are locked)
|
|
Several possibilities:
(NOTE: Camera.main.pixelHeight is the same as Screen.height, if your camera fills the whole screen (as opposed to for example a picture-in-picture camera) EDIT before even posting: I just realized that @DelStrega revived this ancient question from 2010, which is generally not a good idea. But that was when I finished typing, so I'll post my answer anyway. Wow, sorry, didn't realize that actually. I just clicked on "Unanswered" and this came up on the first page. Didn't check the date - my bad :(
Jun 23 '12 at 12:38 PM
delstrega
It does that sometimes just to keep us on our toes:) @wolfram where do you get the year from? I just see month and day...
Jun 23 '12 at 01:27 PM
whydoidoit
@DelStrega - no harm done ;-) I guess the original idea is of course to answer all unanswered questions, but with these old questions it is rather unlikely that it will help the original poster. But of course it might still help people who stumble upon this question, or search for a topic like this! @whydoidoit - it's rather tricky and inconvenient, it might be a problem of the QATO engine itself. "Just" use mouse-over, to get a tool-tip with the full date ;-)
Jun 23 '12 at 01:31 PM
Wolfram
(comments are locked)
|

Screen.width/height are similar, does that help? http://unity3d.com/support/documentation/ScriptReference/Screen-width.html
How does one scale an object to fit the screen dimensions or work out screen.width in relation to the world space? Even make one object the same size of another? Thanks for your help.