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 fingaz1 · Jul 08, 2012 at 09:29 AM · camerajavascripterror

Getting "UnityEngine.GameObject.enabled' not found error

I am trying to setup a menu that has about 15 options, which will bounce between 4 separate cameras depending on what is selected.

I've tried a few different ideas, and non seemed to work, so went to a simple switch statement, but now getting a ton of errors. (see below)

 var camera1 : GameObject;
 var camera2 : GameObject;
 var camera3 : GameObject;
 var camera4 : GameObject;
 
 var CamNum : float = 1; // if the number is one Camera one is enabled , if its 2 Camera two is enabled  
 var menuInput:int = 0;
 
 
 function OnMouseDown(){
 switch (menuInput) {
 case 1:
 CamNum = 2;
 break;
 case 2:
 CamNum = 3;
 break;
 case 3:
 CamNum = 2;
 break;
 case 4:
 CamNum = 1;
 break;
 case 5:
 CamNum = 1;
 break;
 case 6:
 CamNum = 1;
 break;
 case 7:
 CamNum = 1;
 break;
 case 8:
 CamNum = 1;
 break;
 case 9:
 CamNum = 1;
 break;
 case 10:
 CamNum = 1;
 break;
 case 11:
 CamNum = 1;
 break;
 case 12:
 CamNum = 1;
 break;
 case 13:
 CamNum = 4;
 break;
 case 14:
 CamNum = 1;
 break;
 case 15:
 CamNum = 1;
 break;
 }
 
 } 
 
 function Update(){
 
  
 
 if( CamNum == 1){
 
 camera1.enabled = true;  
 camera2.enabled = false; 
 camera3.enabled = false;  
 camera4.enabled = false; 
 
 }
 
 if( CamNum == 2){
 
 camera1.enabled = false;  
 camera2.enabled = true; 
 camera3.enabled = false;  
 camera4.enabled = false; 
 
 }
 
 if( CamNum == 3){
 
 camera1.enabled = false;  
 camera2.enabled = false; 
 camera3.enabled = true;  
 camera4.enabled = false; 
 
 }
 
 if( CamNum == 4){
 
 camera1.enabled = false;  
 camera2.enabled = false; 
 camera3.enabled = false;  
 camera4.enabled = true; 
 
 }
 }

Each of the errors points to this line of code.

 camera1.enabled = true;  

Which is sitting in this block:

 if( CamNum == 1){
 
 camera1.enabled = true;  
 camera2.enabled = false; 
 camera3.enabled = false;  
 camera4.enabled = false; 
 
 }

I'm not sure why its giving an error like this, some help please... Am I missing something simple?

This is the error from the log:

MissingFieldException: Field 'UnityEngine.GameObject.enabled' not found.

Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.FindExtension (IEnumerable`1 candidates) Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.Create (SetOrGet gos) Boo.Lang.Runtime.DynamicDispatching.PropertyDispatcherFactory.CreateSetter () 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
Best Answer

Answer by whydoidoit · Jul 08, 2012 at 09:30 AM

Define your variables as Camera rather than GameObject - GameObject does not have an enabled property (that is a property of certain components) - it does have an active property but in your case just changing the variable definitions should be what you want.

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 fingaz1 · Jul 08, 2012 at 03:24 PM 0
Share

Excellent no more errors, but unfortunately nothing is happening when i click on any of the menu items either :(

Each menu item is labeled in the hierarchy 1-15 and assigned the $$anonymous$$enuInput to match for each one. (1-15) Box collider is on each of the menu items as well. and not set to "is trigger?"

avatar image fingaz1 · Jul 08, 2012 at 03:36 PM 0
Share

Never$$anonymous$$d, I figured it out. The Function Update wasn't being called after the selection from the On$$anonymous$$ouseDown function was made. Now works like a charm, thanks for the assist!!!

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Making the players head face toward the location of the mouse? 1 Answer

Keep getting the Error: Camera' does not contain a definition for `mainCamera' 2 Answers

Expressions in statements must only be executed for their side-effects. 1 Answer

Javascript literal error: unexpected identifier 1 Answer

UnityEngine.Rect' does not have a visible constructor that matches the.... 2 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