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 Conect11 · Sep 27, 2013 at 09:08 PM · c#cameraswitch

Switching multiple cameras

Hello all,

This is a question I was able to figure out earlier, but I've thrown a wrench into it and am hoping someone might be able to help me out. I realized that for all the trouble I'm having trying to figure out keeping playerprefs while switching scenes, saving scenes, etc. there is a much simpler solution to my issues: namely, just have different cameras and build my scene that way. That's how I've made my pause menu, and then this morning I made the game's main menu that way. The main menu shows the view of camera 1, pressing a button pushes you out to camera 2. (the actual game menu) For posterity, here's that script, which I'm having no issues with, it works great:

 using UnityEngine;
 using System.Collections;
 
 public class MainMenuCameraSwitch : MonoBehaviour {
 
 
          public Camera camera1;
      
     public Camera camera2;
      
     bool camera1ActiveBool;
      
      
     void Start () {
      
     camera1.camera.active = true;
      
     camera2.camera.active = false;
      
     camera1ActiveBool = true;
         
     }
      
      
     void Update () {
      
     //use whatever button you want to toggle
     if(Input.GetButtonDown("Action")){
      
     if (camera1ActiveBool == true)
     {
     camera1.camera.active = false;
     camera2.camera.active = true;
     camera2.enabled = true;
     camera1.enabled = false;
      
     //camera1ActiveBool = false;
                 
      //Time.timeScale = 0;
     }
      
     else if (camera1ActiveBool == false)
     {
     camera1.camera.active = true;
     camera2.camera.active = false;
      
     camera1ActiveBool = true;
                  Time.timeScale = 1;
     }
      
     }
     }
     }

Again, that camera script works fine. Pushes me from the title screen to the game. Now I want to introduce a logo, or "Splash screen" right before the title screen. No problem, I thought, just plug this script in the same way, disable the menu camera, and allow the script to enable it. No dice, it kicks right from the logo to either a blank screen (never enabling the menu camera) or right to the game. (bypassing the menu camera entirely) Have experimented with unchecking the box in the top left corner of the inspector, checking it, retagging it as a regular camera and tagging the logo camera as main, etc. When that didn't work I thought maybe since I had the script already attached elsewhere that it might have been an issue, so I put a different one on (now having two camera switch scripts) shown here:

 var camera1 : Camera;
      
     var camera2 : Camera;
      
      
      
      
     function Start () {
      
     camera1.camera.active = true;
      
     camera2.camera.active = false;
      
     yield WaitForSeconds(4.0);
     }
     yield WaitForSeconds(4.0); 
      
     function Update () {
      
     
      
     //camera1.camera.active = false;
      
    // camera2.camera.active = true;
      
      
     }

Now, yeah, I know that one is a newb fueled disaster. I knew that yield WaitForSeconds could not exist inside update, so tried putting it in a couple of different places, the intention being finally that the splash screen would pop up, appear for four seconds, then that camera would disable and the title menu camera would enable, and then the player could press the action button, which would send them to the game world. It seems that the menu camera is never in fact disabled, as the audio clip attached to it plays, even though the splash screen camera has no audio listener or source. So what essentially happens right now is any of the following, depending on what box I have checked in the upper left corner of the inspector:

Splash screen shows, but music plays Title Screen doesn't show, just black screen__pressing "action" still kicks player to main game camera.

Or

Splash screen doesn't show_Title Screen Shows, music is fine_Kicking to main camera successful with press of action button.

So steps two and three work fine, it's just getting that splash screen to appear for a certain number of seconds that's been the issue. My worry is that maybe having two camera switch scripts on a single camera (actually on a game object, and then the script calls the camera) might be confusing things. Any and all advice is humbly appreciated. Thanks, and God bless.

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 Fattie · Sep 28, 2013 at 10:04 AM 0
Share

you simply have to have a routine that carefully turns all cameras OFF< and then turns one ON. it's a program$$anonymous$$g basic

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.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

How to set main camera? 3 Answers

Instantiated GuiTextures not showing 1 Answer

camera movement problem? 1 Answer

setting a character controller orientation by script 1 Answer

Switching camera effects 1 Answer


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