How To Adjust The Camera's Width And Height In Unity
- Spaces
- Default
- Assistance Room
- META
- Moderators
-
- Topics
- Questions
- Users
- Badges
- Dwelling house /
ane
scaling (Resizing) orthographic camera in 2D mode
Ok guys starting time fourth dimension out with 2d games in unity. I hope this is a really unproblematic questiom (Merely not a dumb one). Can i scale a 2nd orthographic camrea like you would a normal object? the height to width ratio is not what i want but i tin can only seem to scale information technology in all centrality at once, and non change the ratio itself. Im following a tutorial and the camera on at that place is a different size and ratio to the one that unity created for me. A new camera gives me the same dimensions likewise. really frustrating as i need the camera ratio to be right as the colliders in the game arrange with information technology.
Any takers?
3 Replies
· Add your reply
- Sort:
6
Respond by GameVortex · Jan xvi, 2014 at 03:09 PM
The size value for orthographic camera basically decides the Height of the photographic camera while the Aspect Ratio of your game decides the width of the photographic camera. When increasing the "elevation" size on the photographic camera the width is also increased to proceed with the current attribute. In the top left of the Game view you can alter the current Attribute Ratio to whatever you need it to be.
Retrieve to later specify in the Player Settings a resolution with the same aspect before you build the game.
five
Answer by Elon · Jul xv, 2014 at 07:fifty PM
I've been though this, heres my code (ofc you can change the min\max numbers) using UnityEngine; using Organization.Collections;
public class CameraAdjust : MonoBehaviour { // Use this for initialization void Start () { camera.orthographicSize = 6; // Size u want to kickoff with } // Update is called once per frame void Update () { if(Input.GetKey(KeyCode.Q)) // Modify From Q to anyother key yous want { camera.orthographicSize = photographic camera.orthographicSize + i*Time.deltaTime; if(photographic camera.orthographicSize > 8) { camera.orthographicSize = 8; // Max size } } if(Input.GetKey(KeyCode.E)) // Also you can alter Eastward to anything { camera.orthographicSize = camera.orthographicSize - 1*Time.deltaTime; if(camera.orthographicSize < 6) { camera.orthographicSize = six; // Min size } } } }
Hope you'll notice it usefull
0
Respond past hemankag · Jun 26, 2018 at 03:02 AM
@p_unity. U can alter it by clicking on free aspect carte in the top left .u can employ the presets, or customize information technology by clicking on footling plus sign in the bottom.
Your answer
Welcome to Unity Answers
The best place to ask and answer questions nigh evolution with Unity.
To help users navigate the site we accept posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Brand certain to cheque out our Cognition Base for normally asked Unity questions.
If you are a moderator, see our Moderator Guidelines folio.
We are making improvements to UA, run into the listing of changes.
Follow this Question
Related Questions
Source: https://answers.unity.com/questions/618330/scaling-resizing-orthographic-camera-in-2d-mode.html
Posted by: carterhinatimsee.blogspot.com
Hi, I am trying to use your code, but I am getting post-obit error
error CS1061: Type
UnityEngine.Component' does non contain a definition for
orthographicSize' and no extension methodorthographicSize' of type
UnityEngine.Component' could be found. Are y'all missing an assembly reference?Try using UnityEngine.Camera.master. ins$$anonymous$$d of Camera.