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 ashjack · Nov 30, 2013 at 01:01 AM · c#javascriptbooleandisableseparate

Can't use script name as variable type?

I am fixing a bug that my game has. The bug is that when the game is paused, some scripts are disabled (specifically camera orbiting ones), but if you click on a brick(programmed to disable the same scripts when being dragged), the camera orbit disabling scripts are enabled even though it is in pause mode because of an OnMouseUp function.

When trying to fix the bug with a boolean in the pause menu script(C#), and I need to change that boolean from the camera orbit script(js). But I get the following similar errors:

Assets/disableMouseOrbit.js(13,71): BCE0005: Unknown identifier: 'PauseMenu'.

and

Assets/disableMouseOrbit.js(22,41): BCE0005: Unknown identifier: 'PauseMenu'.

Here are my scripts (sorry if they are messy):

Pause Menu:

 using UnityEngine;
 using System.Collections;
 
 public class pauseMenu : MonoBehaviour {
 
 public bool paused  = false;
 bool isButtonVisible = true;
 Rect buttonRectangle = new Rect(100, 100, 100, 50);
 public MouseOrbit mouseOrbitScript;
 public PartMenu partMenu2;
 
 
  
 void Start()
 {
     mouseOrbitScript = Camera.main.GetComponent<MouseOrbit>();
 
     
 }
  
 void Update () {
  
  
  
     if(Input.GetKeyUp(KeyCode.Escape) && paused == false)
    {
    
    paused = true;
    isButtonVisible = false;
    Time.timeScale = 0;
    mouseOrbitScript.enabled = false;
    GetComponent<PartMenu>().enabled = false;
   
    
    
    }
    else if(Input.GetKeyUp(KeyCode.Escape) && paused == true) {
    
    
    paused = false;
    mouseOrbitScript.enabled = true;
    isButtonVisible = true;
    Time.timeScale = 1;
    GetComponent<PartMenu>().enabled = true;
    
    }
    
    
  
 }
 
 void OnGUI ()
 {
     if ( isButtonVisible ) {
         if ( GUI.Button(buttonRectangle, "Turn Me Off") ) {
             isButtonVisible = false;
             }
         }
     }
 }

Disable Camera Orbit:

 var mouseOrbitScript : MouseOrbit;
 var pauseMenuScript : GameObject;
  
 function Start()
 {
     mouseOrbitScript = Camera.main.GetComponent(MouseOrbit);
     GetComponent(Rigidbody).transform.rigidbody.isKinematic = true;
     
 }
  
 function OnMouseOver ()
 {
     if(Input.GetKeyDown(KeyCode.Mouse0)&&pauseMenuScript.GetComponent(PauseMenu).paused == false)
     {
         mouseOrbitScript.enabled = false;
         GetComponent(Rigidbody).transform.rigidbody.isKinematic = false;
     }
 }
  
 function OnMouseUp()
 {
     if(pauseMenuScript.GetComponent(PauseMenu).paused == false){
     mouseOrbitScript.enabled = true;
     GetComponent(Rigidbody).transform.rigidbody.isKinematic = true;
     }
 }

There may still be bits of code that were from previous attempts to fix the bug, please point them out if you see any.

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

Answer by billykater · Nov 30, 2013 at 11:07 AM

The first issue really was the different casing, as iwaldrop already mentioned. Always remember that all programming languages in unity are case sensitive when it comes to variable/class names.

The second problem is that you are mixing c# and unityscript and want to reference one from the other. I suggest you read up on the compilation order of unity: http://docs.unity3d.com/Documentation/Manual/ScriptCompileOrderFolders.html. This way you can fix the problem.

Though in the long run I strongly discourage you from using more than one language as you can only fix it for one way (either c# -> unityscript or unityscript -> c#). You will most probably run into several errors of this kind as you project grows.

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
0

Answer by iwaldrop · Nov 30, 2013 at 08:58 AM

It looks a lot to me like you've named the pause menu script 'pauseMenu' instead of 'PauseMenu'. Classes should always start with an uppercase letter.

 public class pauseMenu : MonoBehaviour
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 ashjack · Nov 30, 2013 at 10:22 AM 0
Share

I changed the name and class declaration, but still no luck

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

19 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

Related Questions

Disable JS from C# 1 Answer

Multiple Cars not working 1 Answer

Disable script does not work 1 Answer

Sending the C# function parameter to JS function. 1 Answer

Distribute terrain in zones 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