Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by SystemIsGod · Mar 11, 2013 at 08:46 PM · androidcameraorientation

Android camera change based on orientation.

I'm looking for the most simple way to check to see if the orientation of the phone or tablet was changed, if it was switch to another camera. I've searched a great deal, and I've attempted to create my own, but I don't seem to understand it. This is what I made.

 var camera1:Camera;
 var camera2:Camera;
 
 function Start(){ 
 camera1.enabled = true;
 camera2.enabled = false;
 }
 
 function Update(){
 if (Screen.orientation(ScreenOrientation.Landscape))    {
 camera1.active = true;
 camera2.active = false;
 }
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Khada · Mar 12, 2013 at 03:41 PM

Judging from the reference page it should be:

 if(Screen.orientation == ScreenOrientation.Landscape)
     //...
 else
     //...

You might want to do look at some tutorials on enums to better understand how they work.

Comment
Add comment · Show 7 · 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 SystemIsGod · Mar 12, 2013 at 05:47 PM 0
Share

Hi, I've basically found this code somewhere else and changed it for what I need, I've done exactly as you've stated for the if statement, however this eror shows up "Assets/screen.js(12,17): BCE0044: expecting :, found '='." the line is camera1.enabled = true;

avatar image Khada · Mar 13, 2013 at 12:19 AM 0
Share

If what I've posted is the correct answer, you should mark it as answered. If it's not and you've found the answer yourself, you can post and mark your own answer. This is to keep the site clear, and so contributors can see that the question is answered, and others can benefit from the answer etc.

The error you mention is a syntax error. If you post the offending code I can tell you exactly what's wrong.

avatar image SystemIsGod · Mar 13, 2013 at 12:21 AM 0
Share
 var camera1:Camera;
 var camera2:Camera;
  
 function Start(){ 
 camera1.enabled = true;
 camera2.enabled = false;
 }
  
 function Update(){
 if (Screen.orientation == ScreenOrientation.Landscape){
 camera1.active = true;
 camera2.active = false;
 }
 }
avatar image Khada · Mar 13, 2013 at 12:49 AM 0
Share

That error doesn't look like it's for that block of code. Is that the entire contents of your Assets/screen.js script?

Also, you should be using camera.enabled ins$$anonymous$$d of camera.active.

avatar image SystemIsGod · Mar 13, 2013 at 01:27 AM 0
Share

Sorry, I was using the code I had above, this is proper

 var camera1:Camera;
 var camera2:Camera;
 
 function Start(){
 camera1.enabled = true;
 camera2.enabled = false;
 }
 function Update()
 {
 if (Screen.orientation == ScreenOrientation.Landscape);{
 camera1.enabled = true;
 camera2.enabled = false;
 }
 }

error: Assets/NewBehaviourScript.js(11,17): BCE0044: expecting :, found '='.

Show more comments

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

11 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

Related Questions

Android - Camera orientation 1 Answer

open camera on android with orientation? 1 Answer

Screenshot function not working properly ,it records button on UI ? 0 Answers

Detect Android Rear Camera 2 Answers

Native camera FOV? 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