• 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
Question by byurocks23 · Mar 21, 2014 at 06:27 AM · javascriptfloatstaticmember

BCE0019: 'distanceScore' is not a member of 'float'. (JavaScript)

BCE0019: 'distanceScore' is not a member of 'float'.

I am trying to access a static variable from another script and attach that value to a float variable. Here is my code for the static variable:

 static var distanceScore: float;

and the number gets assigned later in the script

here is the code for the variable i'm trying to assign:

 var score: float;
 
 score = score.distanceScore;

How can I fix this? (let me know if you think some of my other code might be the problem and I'll be sure to post it.)

Comment

People who like this

0 Show 1
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 phuzik · Nov 29, 2015 at 10:00 AM 0
Share

I have the same problem after the upgrade to the Unity 5. Static variables are not working.

Assets/Sktypty/bolen.js(17,14): BCE0019: 'aktualnyLewel' is not a member of 'UnityEditor.Menu'.

This is my bolen.js

 //boen.js
 
 #pragma strict
 
 public var lewel:int; 
 
 function Start () {
 
     Menu.aktualnyLewel=lewel;
 }

And my Menu.js:

 //Menu.js
 
 #pragma strict
 
 public static var aktualnyLewel=2;
 
 function Start(){
 
     Debug.Log(aktualnyLewel.ToString());
 }

I can not find a solution

 GetComponent.().aktualnyLewel=lewel;

It also does not help nor is:

 var menu : Menu;
 menu = GameObject.Find("Menu").GetComponent(Menu);
 menu.aktualnyLewel=lewel;


 
 




2 Replies

· Add your reply
  • Sort: 
avatar image

Answer by sriram90 · Mar 21, 2014 at 06:45 AM

You have to try with, Class name and access that members from another script. Basic scripting will help to fix this, here you go.

Test1.js

 public static var distanceScore : float = 100.0f; 

Test2.js

 var score : float;
 
 function Start () 
 {
 score = Test1.distanceScore;
 print("Score : "+score); //Prints 100.
 }
Comment

People who like this

0 Show 6 · 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 byurocks23 · Mar 21, 2014 at 06:55 AM 0
Share

This is still giving me the same error

avatar image sriram90 · Mar 21, 2014 at 07:01 AM 0
Share

Whether you attached both the scripts to game Object ? If so, it'll work 100% And paste the code what you modified.

avatar image byurocks23 · Mar 21, 2014 at 07:05 AM 0
Share

What I did was I added public in front of my static variable. These scripts are attached to a game object, but not the same game object. And I changed the name of the variable score to scoreFinal so that it doesn't match the name of the script "score"

avatar image sriram90 · Mar 21, 2014 at 07:16 AM 0
Share

You have to access class member using that Class name . like score = Test1.distanceScore; score = score.distanceScore; wont work. Try to learn basic programming.

avatar image byurocks23 · Mar 21, 2014 at 07:23 AM 0
Share

I know, score is the name of the script. That's why I changed the variable name score to scoreFinal.

Show more comments
avatar image

Answer by phuzik · Dec 03, 2015 at 08:18 AM

My problem solved. I had to change the name of the script. The name "Menu.js" is prohibited in Unity5.x . In Unity3.x or Unity4.x was OK. My project have GUI skin with name "Menu" and scene with name "Menu". Maybe now this it is problem.

Comment

People who like this

0 Show 0 · 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

23 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 avatar image avatar image avatar image avatar image

Related Questions

Setting Scroll View Width GUILayout 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

variable = true from another script 2 Answers

print to only two decimal places. 2 Answers

Public and Static Variables 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