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 Luiz_Thiago · Jan 22, 2015 at 12:07 PM · iosarrayindexoutofrangeexception

IndexOutOfRangeException only on iOS! Android / PC is ok!!

Hello everybody!

I have a problem that is driving me crazy! I'm generating a three-dimensional array, and when I run inside the Unity, or Android, everything works perfectly.

But when I run on iOS, happens IndexOutOfRangeException error when creating the array!

Anyone have any idea why?

 void GenerateWorldData () {
         WorldData = new byte[Width, Height, Depth];
         _perlingNoise = new PerlingNoise(Seed, 15);
 
         Debug.Log(WorldData.GetLength(0) + "," + WorldData.GetLength(1) + "," + WorldData.GetLength(2));
 
         for (int x = 0; x < Width; x++)
         {
             for (int y = 0; y < Height; y++)
             {
                 for (int z = 0; z < Depth; z++)
                 {
                     if (y >= 24 && y <= 24 + 2)
                     {
                         WorldData[x, y, z] = (byte)VoxelType.Occlusion;
                     }
                     else
                     {
                         int stone = _perlingNoise.GetPerlingNoise(x, z, 18) + 15;
                         int dirt = stone + _perlingNoise.GetPerlingNoise(x, z, 8) + 10;
                         int grass = dirt + 1;
 
                         if (y <= stone) 
                         {
                             WorldData[x, y, z] = (byte)VoxelType.Stone;
                         }
                         else if(y <= dirt)
                         {
                             WorldData[x, y, z] = (byte)VoxelType.Dirt;
                         }
                         else if(y <= grass)
                         {
                             WorldData[x, y, z] = (byte)VoxelType.Grass;
                         }
                         else
                         {
                             WorldData[x, y, z] = (byte)VoxelType.Air;
                         }
                     }
                 }
             }
             Debug.Log(x);
         }
 
         Debug.Log("Finished");
     }

And this is the error that appears on the xCode console:

 IndexOutOfRangeException: Array index is out of range.
   at (wrapper managed-to-managed) object:ElementAddr (object,int,int,int)
   at World.GenerateWorldData () [0x00000] in <filename unknown>:0 
   at World.CreateWorld () [0x00000] in <filename unknown>:0 
   at World.Awake () [0x00000] in <filename unknown>:0 
  
 (Filename:  Line: -1)

Comment
Add comment · 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 DaDonik · Jan 22, 2015 at 12:10 PM 0
Share

Hmm strange indeed. Have you tried it with a smaller array, maybe your apple device is not up to the task?

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by hav_ngs_ru · Jan 22, 2015 at 12:23 PM

like a rain-dance... have you tried to use integer instead of byte?

but the better way is the deep debugging. Try to detect what x,y,z values causes exception? log values and see what conbinations was the last. at the same time detect the exact line where it happens. then it will be more clearly (or less darkly :))

Comment
Add comment · Show 4 · 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 Luiz_Thiago · Jan 22, 2015 at 12:26 PM 0
Share

The X, Y and Z go at last "10", than the error appears... =( I will try change the byte type to int...

avatar image Luiz_Thiago · Jan 22, 2015 at 01:17 PM 0
Share

Thats work! Its the BYTE type... I change to INT and works!!!

avatar image hav_ngs_ru · Jan 22, 2015 at 11:15 PM 0
Share

sometimes I'm lucky -))))))

avatar image Luiz_Thiago · Jan 22, 2015 at 11:32 PM 0
Share

I dont know why, but iOS build wont support uint, bytes, ufloat types...

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

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

Related Questions

IndexOutOfRange Issue 1 Answer

IndexOutOfRangeException C# 1 Answer

Array index is out of range 0 Answers

Waypoint system: loop and back-forth operations 1 Answer

Unity iOS unreproducable crashes in methods of ArrayList with mono_gc_out_of_memory 0 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