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 /
This question was closed Aug 01, 2016 at 06:45 PM by Bogsse for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Bogsse · Aug 01, 2016 at 03:42 PM · alphamapsplatmapseditor-crash

terrainData.SetAlphamaps trouble.

I am making a prosedualy generated terrain and am trying to apply textures when a point is at a elevation point. I have two textures in the terrain paint system and am trying to apply it to the terrain if a point is above a height.

         for (int x = 0; x < terrain.terrainData.heightmapWidth; x++) {
             for (int y = 0; y < terrain.terrainData.heightmapHeight; y++) {
                 if (pointMap [x, y] > 0.5f) {  //pointMap is a float[,]
                     alphaMap [x, y, 0] = 0; 
                     alphaMap [x, y, 1] = 1;
                 } else {
                     alphaMap [x, y, 0] = 1;
                     alphaMap [x, y, 1] = 0;
                 }
                 terrain.terrainData.SetAlphamaps (x, y, alphaMap);
             }
         }

So far it crashes the editor. If it didn't crash would it work and how do i stop it from crashing. Or do i have to set the splat-maps by code instead of manually in the editor?

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 Bogsse · Aug 01, 2016 at 06:11 PM 0
Share

It seams like it is trying to do something but the editor crashes over and over if i run the code. Am I doing this correctly? I am on a tight schedule.

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by AlucardJay · Aug 01, 2016 at 06:11 PM

Move line 10 out of the for-loops. You only want to set the alphamaps after the whole alphaMap array has been populated.

 for( .... {
 .......
 }
 terrain.terrainData.SetAlphamaps (0, 0, alphaMap);

scripting reference : http://docs.unity3d.com/ScriptReference/TerrainData.SetAlphamaps.html

Comment
Add comment · Show 3 · 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 Bogsse · Aug 01, 2016 at 06:14 PM 0
Share

I will try that. What would i put in the x and y values then. Or are those for offsets?

avatar image Bogsse · Aug 01, 2016 at 06:44 PM 1
Share

I found out that it is just offsets and i can put in values of 0

thank you and i hope other people find this helpful also.

avatar image AlucardJay Bogsse · Aug 02, 2016 at 12:41 AM 0
Share

Oops, sorry about that. Glad you found how to fix it. I have edited the answer correctly and added the scripting reference for future readers.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Splatmap performance question 2 Answers

heightmap resolution and terraindata.getalphamaps 0 Answers

Torch Script Error - Unity crashes 1 Answer

How to use splat maps with materials instead of 2D Textures? 0 Answers

Terrain alphamap fade 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