• 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 rkGio · Oct 14, 2013 at 09:21 PM · camerainspector

Can't add GameObjects to the inspector

Now, I don't really think this makes any sense... I am making a script to change between cameras as asked in my assignment. For my project I'm using the cameras as 'floors' to a dungeon, I did some tests earlier and I do know how to control them, I was making the scripts needed and, this is what my "warp" script looks like.

 #pragma strict
 var Lv1Camera : Camera;
 var Lv2Camera : Camera;
 var warpMessage : boolean; 
 var warpStyle : GUIStyle;
      
 function Start () {
        warpMessage = false; 
        Lv1Camera.enabled = true;
        Lv2Camera.enabled = false;
  
  }
  
 function Update () {
  
 }
 
 function OnTriggerStay(other : Collider)
 {
     if(other.tag == "Player")
     {
         warpMessage = true;
         if (Input.GetMouseButtonDown(1))
         {
             if (Lv1Camera.enabled == true)
             {
                 Lv2Camera.enabled = true;
                 Lv1Camera.enabled = false;
               }
           }
         else if (Lv2Camera.enabled == true)
         {
                 Lv1Camera.enabled = true;
                Lv2Camera.enabled = false;
            }
      }
 }
 
 
 
 function OnGUI()
 {
     if(warpMessage)
         GUI.Label(Rect(0,Screen.height/2,512,512), "Use the Right-Click in your mouse if you are ready for the next level", warpStyle);
 }

I placed the script on my prefab as normal, but, when I try to add the cameras I want to use as variables to the script in the inspector, Unity is just not letting me drag them there. I even tried making a third variable for a GameObject of any kind, and still, unity is not letting me drag objects into this particular script, can anyone tell me the reason why?

Comment
Add comment · Show 5
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 mattssonon · Oct 15, 2013 at 07:39 AM 0
Share

Are you seeing any errors in the console?

avatar image rkGio · Oct 15, 2013 at 07:49 AM 0
Share

no, there are no errors on the console

avatar image mattssonon · Oct 15, 2013 at 07:54 AM 0
Share

Have you tried restarting Unity? It works fine here, I replicated the script and can easily add a Camera:

alt text

avatar image rkGio · Oct 15, 2013 at 08:38 AM 0
Share

I did try restarting unity, but still nothing.

avatar image ClaraNeuhau · Aug 19, 2021 at 07:33 AM 0
Share

I am having EXACTLY the same problem, 8 years and still no answer :(

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by mdyerga · Nov 06, 2018 at 07:11 PM

Thats all well and good but it does not change the prefab in the project window. is there no way to change my prefab to having the game object added?

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
2

Answer by whydoidoit · Oct 15, 2013 at 08:56 AM

Are you trying to add them to the prefab in the project window? That is not possible because the cameras are (and need to be) scene items and you can't add scene items to scripts in the project window because the project window is for things that could be used in any scene.

If that's the case put an object of the prefab type in the scene and add them there.

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

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

18 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

Related Questions

New gameobject to spawn in front of editor camera?, 1 Answer

get editor camera without focus on the scene 0 Answers

Render Texture strange noise error 1 Answer

Skybox - Render Settings vs on a Camera 0 Answers

Change Camera With a Script 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