Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
1
Question by p_unity · Jan 16, 2014 at 02:46 PM · cameraorthographic2d camera

scaling (Resizing) orthographic camera in 2D mode

Ok guys first time out with 2d games in unity. I hope this is a really simple questiom (But not a dumb one). Can i scale a 2D orthographic camrea like you would a normal object? the height to width ratio is not what i want but i can only seem to scale it in all axis at once, and not change the ratio itself. Im following a tutorial and the camera on there is a different size and ratio to the one that unity created for me. A new camera gives me the same dimensions also. really frustrating as i need the camera ratio to be right as the colliders in the game adjust with it.

Any takers?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
6

Answer by GameVortex · Jan 16, 2014 at 03:09 PM

The size value for orthographic camera basically decides the Height of the camera while the Aspect Ratio of your game decides the width of the camera. When increasing the "height" size on the camera the width is also increased to keep with the current aspect. In the top left of the Game view you can change the current Aspect Ratio to whatever you need it to be.

Remember to later specify in the Player Settings a resolution with the same aspect before you build the game.

Comment
Add comment · 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
5

Answer by Elon · Jul 15, 2014 at 07:50 PM

I've been though this, heres my code (ofc you can change the min\max numbers) using UnityEngine; using System.Collections;

 public class CameraAdjust : MonoBehaviour {
     
     // Use this for initialization
     void Start () {
         camera.orthographicSize = 6; // Size u want to start with
     }
     
     // Update is called once per frame
     void Update () 
     {
         if(Input.GetKey(KeyCode.Q)) // Change From Q to anyother key you want
         {
             camera.orthographicSize = camera.orthographicSize + 1*Time.deltaTime;
             if(camera.orthographicSize > 8)
             {
                 camera.orthographicSize = 8; // Max size
             }
         }
 
 
         if(Input.GetKey(KeyCode.E)) // Also you can change E to anything
         {
             camera.orthographicSize = camera.orthographicSize - 1*Time.deltaTime;
             if(camera.orthographicSize < 6)
             {
                 camera.orthographicSize = 6; // Min size 
             }
         }
     }
 }
 

Hope you'll find it usefull

Comment
Add comment · Show 2 · 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 sandeepraj · Jan 22, 2017 at 03:27 AM 0
Share

Hi, I am trying to use your code, but I am getting following error

error CS1061: Type UnityEngine.Component' does not contain a definition for orthographicSize' and no extension method orthographicSize' of type UnityEngine.Component' could be found. Are you missing an assembly reference?

avatar image Rohan_S · Nov 02, 2017 at 11:56 AM 0
Share

Try using UnityEngine.Camera.main. ins$$anonymous$$d of Camera.

avatar image
0

Answer by hemankag · Jun 26, 2018 at 03:02 AM

@p_unity. U can change it by clicking on free aspect menu in the top left .u can use the presets, or customize it by clicking on little plus sign in the bottom.

Comment
Add comment · 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

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

25 People are following this question.

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

Related Questions

Orthographic camera movement clamping 1 Answer

How to make a smash bros-like camera 3 Answers

2D Camera size based on unit width 1 Answer

Making a camera semi-orthographic 2 Answers

Fitting a series Gameobjects within camera view 0 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