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 moinchdog · Dec 21, 2012 at 07:15 PM · errorarrayindexlod

array problem

i get this error

 ArgumentOutOfRangeException: Index is less than 0 or more than or equal to the list count.
 Parameter name: index
 8
 System.Collections.ArrayList.ThrowNewArgumentOutOfRangeException (System.String name, System.Object actual, System.String message) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Collections/ArrayList.cs:3261)
 System.Collections.ArrayList.get_Item (Int32 index) (at /Applications/buildAgent/work/3df08680c6f85295/mcs/class/corlib/System.Collections/ArrayList.cs:2652)
 UnityScript.Lang.Array.get_Item (Int32 index)
 LODSystemEditor.CollapseTest () (at Assets/LODSystem/Editor/LODSystemEditor.js:314)
 LODSystemEditor.ComputeProgressiveMesh () (at Assets/LODSystem/Editor/LODSystemEditor.js:699)
 LODSystemEditor.PreCalculate (UnityEngine.Mesh tmpMesh) (at Assets/LODSystem/Editor/LODSystemEditor.js:464)
 LODEditor.OnInspectorGUI () (at Assets/LODSystem/Editor/LODEditor.js:307)
 UnityEditor.InspectorWindow.DrawEditors (Boolean isRepaintEvent, UnityEditor.Editor[] editors, Boolean eyeDropperDirty)
 UnityEditor.DockArea:OnGUI()


with this piece of code

 for (i = u.face.length - 1; i >= 0; --i) {
             uFace = u.face[i];
             if (uFace.HasVertex(v)) {
                 uFace.deTriangle( his ); // 隣接するリファレンスを除外
             }
       }

this script is a lod system from http://www.macroseed.com/Projects/Unity/Level_of_Detail_System

please help i need this script to work

Thanks Dj

UPDATE : i put a debug.log to display u.face.length and it displayed i and u.face.length as 5

Comment
Add comment · Show 5
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 Dave-Carlile · Dec 21, 2012 at 07:34 PM 0
Share

I would guess that uFace.deTriangle is modifying the number of faces in u.face. Add a Debug.Log message before the uface - u.face[i] line and display the value of i and u.face.length.

avatar image Raigex · Dec 21, 2012 at 08:33 PM 0
Share

Well one problem I can see (maybe) is you are pre subtracting the i.

the way i would do this is:

 for (i = u.face.length - 1; i >= 0; i--) {
     uFace = u.face[i];
     if (uFace.HasVertex(v)) {
          uFace.deTriangle( his ); 
     }
 }

or if you want to use --i then switch

 i>=0  and i= u.face.length -1 

to i > 0 and i = u.face.length

which means even if you pre subtract you will never go past 0. Also like the comment to your question(I think that is the logic of it)

right before the for loop add a debug statement that outputs length then right before u.face[i] put a debug statement what i is.

avatar image Dave-Carlile · Dec 21, 2012 at 08:37 PM 0
Share

The iterator (i-- in this case) doesn't execute until after the loop body executes, so it doesn't matter if you pre- or post-increment.

http://msdn.microsoft.com/en-us/library/ch45axte.aspx

avatar image Raigex · Dec 21, 2012 at 08:40 PM 0
Share

you are right my mistake. will edit my answer

avatar image Raigex · Dec 21, 2012 at 08:44 PM 0
Share

I have used you code and ran a test and theoretically it should work. What kind of what kind of variable is uFace and how does it work, maybe it is the hasVertex function that is crashing it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by moinchdog · Dec 22, 2012 at 12:38 AM

i got it working by doing this

 for (i = u.face.length; i > 0; i--) {
               i=i-1;
             uFace = u.face[i];
             if (uFace.HasVertex(v)) {
                 uFace.deTriangle( his ); // 隣接するリファレンスを除外
             }
       }

and it works

thanks for your help guys.

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

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

11 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

Related Questions

IndexOutOfRangeExeption - Array index is out of range 2 Answers

IndexOutOfRangeException: Array index is out of range 2 Answers

Adding a texture to array textures?! 1 Answer

C# array not behaving as expected 0 Answers

NullReferenceException array 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