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 Mixxathon · May 20, 2013 at 04:38 PM · guicamerasswitching

GUI buttons not showing up

Hi all!

Trying to get a list of all cameras in the scene and represent them as a GUI button, and by pressing a button will be able to switch camera.

I am on the stage of trying to get the list on the screen at all.


 if (GUI.Button(Rect (btnX*2.4, btnY * 1.05 + (btnH /2) , btnH, btnW),"Update Camera list")) {
      cameras = FindObjectsOfType(Camera);
                                   
   if (cameras) {
     for (i=0; i<cameras.length; i++) {
         if (GUI.Button(Rect(btnX * 2.3 + btnW, btnY * 1.2 + (btnH * i), btnW * 3, btnH * 0.5), cameras[i].name)) {

          // Insert Camera Switching Code Here 

           }
         }
       }
     }



No luck so far. If you could help me to get the GUI working and it would be super if you could give med the actual line of code needed to be able to switch the present camera for the one corresponding to the buttonpress.

Thanks in advance.

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
0

Answer by Ashkan_gc · May 20, 2013 at 06:24 PM

for switching you should disable the current camera and enable the clicked one and store the new one as current in a static variable. The problem is that you'll find cameras and put them in a list when a buton is clicked and that's only a frame and in all other times the cameras variable is null and would if would return false as result of it. If cameras is a variable in file scope and not only inside this function then this is not the problem however. But if i'm correct define var cameras in top of your code file. Do you see the main button UpdateCameraList ?

Comment
Add comment · Show 1 · 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 Mixxathon · May 20, 2013 at 09:43 PM 0
Share

Hi and thanks,

Yep, I see the update button, but I do not get a list of new buttons containing the available cameras in the scene.

I have: var cameras : Cameras[]; at the top of the script.

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

14 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

Related Questions

Camera Switching or Scene Changes? 3 Answers

Multiple GUI Cameras peformance consideration 0 Answers

Multiple Camera Switching 1 Answer

Switch Between GUI images 0 Answers

Entering/Exiting Vehicle 90% complete 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