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
1
Question by ina · Dec 23, 2010 at 07:05 AM · cameragameobjectreference

How do you reference different cameras

It looks like there is only a Camera.main - how do you reference other camera's? Is there no better way than GameObject.Find()?

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

2 Replies

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

Answer by taoa · Dec 23, 2010 at 03:48 PM

Camera.allCameras
Comment
Add comment · Show 5 · 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 ina · Dec 23, 2010 at 04:00 PM 0
Share

how do you reference a particular camera though..

avatar image taoa · Dec 23, 2010 at 04:06 PM 1
Share

what is 'a particular camera'? You've got them all here. If there's a special camera that has a special component in it, go though the cameras until you find the one that has said component. If you want a camera that is at a particular position, go through the cameras until you find the one at the right position... and so on.

avatar image Statement · Dec 23, 2010 at 08:24 PM 0
Share

You could name or tag your cameras differently if you want to use them for different purposes. As taoa says, you need to yourself define what makes a camera "particular". What does make it unique? What do you need it for?

avatar image ina · Dec 23, 2010 at 11:09 PM 0
Share

say you create N camera's at runtime (relatively small number), how can you reference just one - you can't assign tag's at runtime.. is there a way to loop through the allCamera array?

avatar image taoa · Dec 29, 2010 at 01:10 PM 0
Share

I'm very sorry to say that and I hope I misunderstood your comment, but... if you don't know how to go through each element of an array, you probably should stay (well) away from scripting/program$$anonymous$$g. Besides, you definitely can apply tag names at run time. I do it all the time: gameObject.tag = "tagname";

avatar image
0

Answer by Paulius-Liekis · Dec 23, 2010 at 08:12 AM

Yes. Declare public variable in your class and assign value in the inspector (you should see editable field for each public variable in the inspector of your object which has your script attached).

Comment
Add comment · Show 2 · 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 ina · Dec 23, 2010 at 10:13 AM 1
Share

What if you are creating camera's at runtime?

avatar image Paulius-Liekis · Dec 23, 2010 at 09:01 PM 0
Share

Well, then you assign it form one object/script to another in runtime.

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

No one has followed this question yet.

Related Questions

Access main camera from different GameObject script 1 Answer

Obect1 to Object2 to Object1 again. Object1 points to Object2. Same Script for both objects that uses gameObject. Why?[Solved] 2 Answers

Getting a camera at runtime 1 Answer

Using the accelerometer to rotate Camera 1 Answer

2 cameras: 1 for GUI and 1 for GameObjects 3 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