Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Evan B · Sep 30, 2011 at 06:00 PM · cameramousemultipleswitch

Switching cameras with the mouse button

Okay, here is my problem. I have a simple 2d (actually it's 3D with an overhead camera, but anyway) I have about 22 cameras going in sequential order and when I click a certain button on the GUi, it switches to the next one. But nothing works and there is no switching of cameras. It should work that when you start at the Main Camera (camera 1)and then when you click the button (which is GUI) you go to the next one (cam 2), but nothing works. Can anyone at least point me in the right direction of what to do?

Comment
Add comment · Show 1
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 Julien-Lynge · Sep 30, 2011 at 07:58 PM 0
Share

We could probably help you if you provided a bit more information about what's going on. Can you add the relevant couple lines of code for the GUI button and camera object activation / deactivation?

1 Reply

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

Answer by Grady · Oct 01, 2011 at 09:08 AM

The standard procedure for switching between cameras when pressing the left mouse button would be something like this:

var camera1 : Camera; var camera2 : Camera;

function Start(){ camera1.enabled = true; camera2.enabled = false; }

function Update(){

 if(Input.GetButonDown("Fire1")){
     if(camera1.enabled == true){
         camera1.enabled = false;
         camera2.enabled = true;
     }
     else{
         camera1.enabled = true;
         camera2.enabled = false;
     }
 }

}

Drag the main camera, (the one that will start active) into the camera1 variable. Then drag the other one into the camera2 variable. I haven't tested this, but it should work, if it doesn't, just comment back and I will fix it, I took a bit of a shortcut that I normally don't, but it should work as is!!!!!

-Grady

Comment
Add comment · Show 4 · 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 breaklaw · Jul 08, 2013 at 05:20 PM 0
Share

Hi Grady, i am trying this out now, but when i try to assign which camera is which in the inspector, the assets folder shows no cameras to select, both cameras are in my assets list... ?

avatar image LightSource · Jul 08, 2013 at 06:09 PM 0
Share

Try drag and drop from your hierarchy.

avatar image breaklaw · Jul 10, 2013 at 02:48 AM 0
Share

thanks dude!

avatar image LightSource · Jul 10, 2013 at 03:44 AM 0
Share

No problem. I'm here 'til tuesday, try the veal.

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

6 People are following this question.

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

Related Questions

Switching cameras with the click of the mouse 1 Answer

Multiple Camera.main.ScreenPointToRay 1 Answer

Add multiple cameras problems 1 Answer

Switching Several Cameras(HorrorGame) 1 Answer

Turn with the mouse instead of with the camera 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