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 Ony · Jan 23, 2012 at 10:45 PM · errorclassclassesbce0019pragma

Class error: BCE0019: 'xxxx' is not a member of 'Object'.

I'm using Javascript and Unity Pro 3.4.2.

Everything works fine, but when I use #pragma strict I get BCE0019 errors.

Here is where I define my variables:

 var characterList : Array = new Array();
 var theEditedCharacterName : String = "";
 var theGender : String = "f";
 
 class characterMisc{
      var name;
     var gender;
 } 

Then, later in the code, I use this:

 // add character to character object list...
 characterList[charListCount] = characterMisc();
 characterList[charListCount].name = theEditedCharacterName;
 characterList[charListCount].gender = theGender;

And... I get the following errors:

 Assets/Scripts/game_manager.js(2554,54): BCE0019: 'name' is not a member of 'Object'. 
 Assets/Scripts/game_manager.js(2555,54): BCE0019: 'gender' is not a member of 'Object'. 

Again, I'm using Javascript. Can someone tell me in simple terms how to resolve this?

Comment
Add comment · Show 4
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 Eric5h5 · Jan 23, 2012 at 11:31 PM 1
Share

There's no reason to ever use Array, all it does is cause problems. Use List ins$$anonymous$$d.

avatar image Ony · Jan 24, 2012 at 01:57 AM 0
Share

I've got arrays scattered all through my code and it's been working for about two years now in a released game. I'd rather not have to go through and rewrite reams of code just to change that if possible. What's wrong with arrays? They have always worked fine for me except now if I try to use pragma strict.

avatar image Eric5h5 · Jan 24, 2012 at 02:46 AM 3
Share

It's generally pretty trivial to change Array to List. Access is the same, and most of the methods are the same (Add, Remove, Reverse, etc.). The main code difference in most cases is how they are declared, and using .Count ins$$anonymous$$d of .length. Ins$$anonymous$$d of

 var characterList : Array = new Array();

use

 var characterList = new List.<character$$anonymous$$isc>();

(You should have import System.Collections.Generic; at the top of the script.) The other code you posted should work the same, except it will be much faster and won't generate errors. And that's what's wrong with Array: it's quite slow, and it's not type safe. Lists also have quite a bit more functionality.

Considering that the majority of platforms that Unity supports require #pragma strict, and even for $$anonymous$$ac/PC/web it's added to new scripts by default in Unity 3.5, it would be a good idea to stop using Array. While it's possible to make Array work with #pragma strict, it requires manually casting to the correct type when you access elements, and that still doesn't help with the speed. This means that if you don't switch the code to List, you're going to have to go through and manually cast everything, which will probably be more time-consu$$anonymous$$g than switching to List. So switching to List could be easier overall and your code will be cleaner and faster.

avatar image Ony · Jan 24, 2012 at 09:31 AM 0
Share

Ah, ok that makes sense then. I didn't realize it would be that relatively simple to switch over to lists, so I'll give it a shot tomorrow and see how it goes. Thanks for the info, Eric.

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Error building Player: Win32Exception - with plugin? 1 Answer

Some problems after switch the game for iOS mode 2 Answers

Is not a Member of Collisions 2 Answers

Access to a variable inside a C# class 2 Answers

Button is not a member of GUI? 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