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 Captain_Dando · Mar 11, 2013 at 11:25 AM · cameravariablespublic

Can't assign camera by dragging it into GUI

Hi everyone. I've created two public Cameras, like this;

 public Camera defaultView;
 public Camera playerAction;

However, when I try to drag a camera from my Hierarchy view to the inspector, it does nothing, I don't get a prompt, and it remains unchanged, like this

alt text

The camera I'm intending to drag is called _Camera, if it means anything. I'm currently using Unity 4

dragndrop.jpg (20.0 kB)
Comment
Add comment · Show 3
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 Khada · Mar 11, 2013 at 12:54 PM 0
Share

Works fine for me and should for you. Do you see your cameras if you click the little circle 'o' thingy?

avatar image Captain_Dando · Mar 11, 2013 at 01:16 PM 0
Share

I see them, and attempting to add them through that menu yields the same results. Are you using unity 4? I switched recently and I have the feeling that it may be the cause

avatar image Khada · Mar 11, 2013 at 01:21 PM 0
Share

Yea, I'm in 4. You may be right about a merge being the cause. I couldn't say. Sucks, but yea... Should work :|

2 Replies

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

Answer by Captain_Dando · Mar 18, 2013 at 11:06 AM

After a lot of testing I discovered that I had a script named Camera that was conflicting with Unity's own Camera behaviour. changing the name seems to have solved it. This didn't show up in the console until I removed all of the scripts and added them back in

Comment
Add comment · 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
1

Answer by Bunny83 · Mar 11, 2013 at 01:26 PM

I guess you try to assign a scene object to a variable in a prefab which doesn't work. Prefabs can only reference objects from the project but not form a scene since it's not geven that the scene is loaded when you use the prefab.

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 Captain_Dando · Mar 11, 2013 at 01:34 PM 0
Share

The object I'm referencing, and the objects I'm referencing are not prefabs, they are arranged as you see below, the script is kept on the _Game $$anonymous$$aster game object.

hough from what you describe I think this may be caused by the camera loading after the script has run. Is that kind of thing possible?

alt text

hierarchy.jpg (35.3 kB)
avatar image Bunny83 · Mar 11, 2013 at 02:30 PM 0
Share

No, not really. Hopefully you talk about assigning the references at edit-time?! If the script containing the variables is also a scene object there should be no problem assigning other scene objects. Do you use a custom inspector for your class?

Usually it doesn't matter, but do you drag the gameobject onto the variable or the component? To drag the component you have to open another inspector window (the "tab"-context-menu at the top right of an editorwindow) and select "Add Tab" -> "Inspector". Lock one of the inspector windows on your manager object by clicking the lock icon at the top of the inspector. Now you can select your other object that has the camera component attached. Now grab the components header line and drag it over to the variables.

Btw: Does the cursor change when you enter the variable field while dragging the component / gameobject? Are you sure you don't have any strange editor scripts somewhere (AssetPostProcessors, ....)?

Does the script have the ExecuteInEdit$$anonymous$$ode attribute? If so is there any code in Update which could overwrite the content of your variables?

I've moved my projects to U4 quite a while ago. I had some issues, but mainly "SetActive" stuff. All in all i migrated without any unexpected trouble.

avatar image Captain_Dando · Mar 11, 2013 at 02:42 PM 0
Share

I definitely add it during edit time, and I've not ventured into custom inspectors so I don't think that might have been the problem. I drag the camera from the hierarchy to the camera field on my script (component) on my Game $$anonymous$$aster Gameobject. When I am dragging it over the field it is surrounded by a blue outline, as it should be, but when I let go, nothing happens.

The camera itself is a generic camera added though unity's menus, withou any special components. both are unable to be added, so I think it's a problem with the Game $$anonymous$$aster script. I'm not aware of any AssetPostProcessors, and I don't have anyhing like tha in my script. it also doesn't have an Update function currently.

On a side note, on a previous project I created a camera variable in the same way, while watching a tutorial. I followed his script to a tee, but when I was told to drag the camera onto the component, nothing happened, so I think something may be wrong with unity, or I changed something and can't remember what it was. Other data types, such as textures can still be applied in that way though.

avatar image Captain_Dando · Mar 13, 2013 at 10:13 AM 0
Share

Is there a way to assign it in code?

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

12 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

Related Questions

How to make camera position relative to a specific target. 1 Answer

Problem exposing public variable to Inspector in C# 2 Answers

script is treating all enemies as one, instead of them as individuals. 2 Answers

public private and static variables in js 1 Answer

Variable Not Changing In Method 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