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 joseph b · May 10, 2011 at 06:40 PM · errorarraypushbce0019

error for array functions

ive been working on my pahing script and it works up to line 23 and 26 i get this eror mesige for both those lines.

Assets/controler.js(22,31): BCE0019: 'Push' is not a member of 'score[]'.

public var curwp : Transform; public var open : score[]; public var close ; var bestrate : float = 10000; function Start () { open = GetComponentsInChildren.<score>(); }

function Update () { bestrate = 10000; for (var val : score in open){ if (val.tlscr < bestrate){ bestrate = val.tlscr; print (bestrate); } } num = 0; for (var val : score in open){

     if (val.tlscr == bestrate){
         val.transform.renderer.material.color = Color.magenta;
         print (val);
         close.Add (val);
         print (close);
         print ("close = " + close);
         open.RemoveAt(num);
     }
 num += 1;
 }

}

any hints to what it could be???

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
Best Answer

Answer by almo · May 10, 2011 at 07:26 PM

If you want to use Push and stuff on arrays, you need to declare your variables a certain way. When you use the

public var myArray : float[];

construct, it's a C# array which does not have Push or RemoveAt.

Here's an example that pushes a float onto one array, and an object onto another.

public var testobjarr : Array; public var testfloatarr : Array;

function Start() { testfloatarr = new Array(); testobjarr = new Array(); }

function Update () { if(testfloatarr.length < 3) { testfloatarr.Push(1); } if(testobjarr.length < 1) { testobjarr.Push(this); } }

Comment
Add comment · Show 5 · 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 joseph b · May 10, 2011 at 07:31 PM 0
Share

so do i need to youse function start and declare like that ??

avatar image joseph b · May 10, 2011 at 07:36 PM 0
Share

ok thanks that worked :) ;)

avatar image almo · May 10, 2011 at 07:43 PM 0
Share

Glad to help. The C# arrays Jessy is referring to are faster and more efficient, so you might want to learn to use those some time.

avatar image Eric5h5 · May 10, 2011 at 08:02 PM 0
Share

It's not a "C# array" though. Typically they are called built-in arrays, or .NET arrays. Also, the JS Array class is slow and obsolete; use List ins$$anonymous$$d.

avatar image almo · May 10, 2011 at 08:07 PM 0
Share

Ok, thanks for the info on .NET. :)

avatar image
1

Answer by Jessy · May 10, 2011 at 06:59 PM

Push, Add, and RemoveAt, are in fact, not members of Array.

You probably want to make open a List.<score>, instead.

import System.Collections.Generic;

var moreDescriptiveNameThanOpen = List.<Score>(GetComponentsInChildren.<Score>());

(Score is a class, and therefore should be in PascalCase, not camelCase.)

Comment
Add comment · Show 7 · 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 joseph b · May 10, 2011 at 07:02 PM 0
Share

list add that makes sence to me but what do you mean by making a list open

avatar image Jessy · May 10, 2011 at 07:03 PM 0
Share

No, I said make open a List. This is also a good demonstration of how bad variable names can be confusing. ;-)

avatar image joseph b · May 10, 2011 at 07:05 PM 0
Share

o sory my bad how do you make it a list is ther an eqivelent of [] or somthing

avatar image almo · May 10, 2011 at 07:09 PM 0
Share

What about: http://unity3d.com/support/documentation/ScriptReference/Array.html According to that, Push, Add, and RemoveAt are members of Array. Jessy's link is to C# arrays.

avatar image joseph b · May 10, 2011 at 07:10 PM 0
Share

thats true it dose say that push and add are members of array acording to the scripting refrences

Show more comments

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

No one has followed this question yet.

Related Questions

Accessing array in another script - Error message 2 Answers

Getting ArgumentOutOfRangeException on array c# 1 Answer

C# custom class array error in adding a new entry. 1 Answer

IndexOutOfRangeExeption - Array index is out of range 2 Answers

transform array gives error. why? 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