Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by RickDeschenes · Apr 06, 2016 at 08:51 PM · rangeargumentexception

TerrainModify.UpdateArea IndexOutOfRangeException: Array index is out of range

I have been updating the terrain in the Cities: Skyline map editor with a mod. If I keep the update area small enough than there is no issue. However when I select a larger area and update the values for height in the array that I am getting a error from outside my code during the Terrain.UpdateArea call. So my code loops trough the height array and updates the height if the coordinates fall into my selected area. then I send update area call which uses the array internally and updates the map. This all is working however I am getting random errors like the one shown below, see the code snippet below to error for additional details. Source code: https://github.com/RickDeschenes/AnotherTerrianTool Error Log details: IndexOutOfRangeException: Array index is out of range. at TerrainModify.UpdateAreaImplementation () [0x00000] in :0 at TerrainModify.UpdateArea (Int32 minX, Int32 minZ, Int32 maxX, Int32 maxZ, Boolean heights, Boolean surface, Boolean zones) [0x00000] in :0 at AnotherTerrain.AnotherTerrainTool.ApplyUndo () [0x00000] in :0 at AnotherTerrain.AnotherTerrainTool.OnToolGUI (UnityEngine.Event e) [0x00000] in :0 at ToolBase.OnGUI () [0x00000] in :0 (Filename: Line: -1) Simulation error: Array index is out of range. at TerrainModify.UpdateAreaImplementation () [0x00000] in :0 at TerrainModify.EndUpdateArea () [0x00000] in :0 at SimulationManager.SimulationStep () [0x00000] in :0 at SimulationManager.SimulationThread () [0x00000] in :0 [Core] Code private array instance

     readonly ushort[] m_rawHeights = Singleton<TerrainManager>.instance.RawHeights;
 //validate the size of the array
 m_maxArea = m_rawHeights.Length;
 //1168561 is 1080x1080 the map area
 
 for (int i = minZ; i <= maxZ; i++)
                 {
                     for (int j = minX; j <= maxX; j++)
                     {
                         int num = i * 1081 + j;
                         //We want the new height in the new/raw
                         m_rawHeights[num] = finalHeight;
                     }
                 }
                 //TerrainModify.UpdateArea(minX - 1, minZ - 1, maxX + 1, maxZ + 1, true, false, false);
                 //we need to update the area in 120 point sections
                 for (int i = minZ; i <= maxZ; i++)
                 {
                     for (int j = minX; j <= maxX; j++)
                     {
                         TerrainModify.UpdateArea(j, i, Math.Max(j + 120, maxZ), Math.Max(i + 120, maxX), true, true, false);
                         //log = j + ", " + i + ":" + Math.Max(j + 120, maxZ) + ", " + Math.Max(i + 120, maxX);
                         //LoadingExtension.WriteLog("Processing: " + log);
                         j += 119;
                     }
                     i += 119;
                 }

The code updates the map but I get the out of range error. I wrapped these calls in try catch but nothing was trapped so I have to assume this is being trapped internal to the game itself. the thing is the error only shows Details No Details: I found the log by searching the hard drive.

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Argument out of range - 2 year old project 1 Answer

canseetarget how to? 0 Answers

EnemyAI code help 0 Answers

Asset Null Exception - No assetGUID 0 Answers

Hello Devs, I'd like to be able to keep track of my slider values for instance current value and previous value and then I'd like to perform action based on if currentvalue is greater or less then the previous value, how do i model this? 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