• 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 ramiallam · Jun 21, 2014 at 03:30 PM · c#camera2dresolutionscreen

Fixing the camera's left side in a 2D Game in all screen resolutions

I just started making a 2D game using unity and I have a resolution & cam problem. I have a 2D terrain and i'm trying to fix the left side of the cam to the left side of the terrain. However, when I change the screen resolution to iphone 4 for example, the left side is hidden. I tried this script for the cam but it's not working :

 void Awake()
 {        
     Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width/ 2, Screen.height / 2,-10));
     Camera.main.orthographicSize = ray.origin.y;
     transform.position = new Vector3 (ray.origin.x, ray.origin.y,-10);  
 }




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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

How to letterbox the screen and have pixel perfection in a 2d game 0 Answers

2D Game. Screen, Camera and coordinates. 0 Answers

Changing screen resolution is cutting the very edge of my screen off 1 Answer

Why is Input.mousePosition returning wired values using Cinemachine 2D with dynamic following? 0 Answers

Camera view different screen sizes? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges