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 /
  • Help Room /
avatar image
0
Question by nicho247 · Sep 17, 2015 at 04:46 AM · c#cameracamera viewport

c# multiple camera help

Hi There,

I have setup a simulation, of which it is just running continuously. I have setup some different points of view with cameras all capturing the same thing from different spots. I have used the viewport rectangles of each camera to form a perimeter around the bottom and right side of my screen. The left side and top side of the screen, I would like to have it also be a camera which serves as the "main", enlarged view. When the user clicks on one of the smaller camera view points, it switches the "main" big camera over to this view point.

I have setup UI buttons over each camera to allow the click functionality, but am having trouble scripting the code to make this happen. All of the camera switching code examples I've seen, work by enabling or disabling cameras, but if I do this, it would also disable my small viewport cameras (deal-breaker). Any ideas?alt text

screenshot-ex.png (43.8 kB)
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
Best Answer

Answer by sys12 · Sep 17, 2015 at 08:05 AM

I think you can do something like updating the rectangles of the cameras. E.g.

 Cameras[0].rect = new Rect(0f, 0f, 0.5f, 1f);

http://docs.unity3d.com/ScriptReference/Camera-rect.html

This probably is what you want.

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 nicho247 · Sep 18, 2015 at 06:09 AM 0
Share

Hey sys12,

I initially did not want to do it like this, but in the absence of any other ideas....I figured it out after a few hours of trial and error. Thanks for the headstart in the right direction.

I stored all my viewport camera rects into rect variables.

 private Rect m = new Rect(0.00f,0.33f,0.80f,0.67f);

Setup logic on the button gui scripts to if button A was pressed, set camera A to the main view (and set all other cameras to their stored camera positions).

 GameObject.FindGameObjectWithTag("CameraViewaboveSun").GetComponent<Camera>().rect = m;

I then repeated this code for each button, B, C, D, etc.

Only drawback is I now have blank/void spot when a camera from the perimeter moves to the main spot. $$anonymous$$eh.

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

30 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 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

Clamping when Zoom changes? 0 Answers

code error CS0119 field of view script 1 Answer

How to access camera Dont Clear in camera clear flags using c# 1 Answer

Move camera between canvases in UI menu 0 Answers

How to make a Camera follow an object and then distance itself from the object when a button is held down? 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