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 Sep 28, 2015 at 07:24 PM by DeadKenny for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by DeadKenny · Sep 28, 2015 at 10:54 AM · terrainproceduralintterraindatadetail

Terrain set detail layer problem.

Ok, so I have this terrain that cuts itself up and then places stuff on. This code I have places details on the terrain using the Terrain scripts detail prototypes. However it only places the first detail in the list. I cannot get it to place anything other than the first. The last integer at the end of GetDetailLayer is supposed to do it but, nothing shows up if I change it to above 1. Setting it to 1 still only shows the first detail. I'm very confused please help. It should be working, I don't get it.

    void PlaceDetail(Terrain t, Vector3 pos, float radius)
     {
 
         int TerrainDetailMapSize = t.terrainData.detailResolution;        
         float pixelSize = TerrainDetailMapSize / t.terrainData.size.x;        
         Vector3 TexturePoint3D = pos - t.transform.position;
         TexturePoint3D = TexturePoint3D * pixelSize;    
         float[] xymaxmin = new float[4];
         xymaxmin[0] = TexturePoint3D.z + radius;
         xymaxmin[1] = TexturePoint3D.z - radius;
         xymaxmin[2] = TexturePoint3D.x + radius;
         xymaxmin[3] = TexturePoint3D.x - radius;
         int[,] map = t.terrainData.GetDetailLayer(0,0, t.terrainData.detailWidth, t.terrainData.detailHeight, 0);
         for (int y = 0; y < t.terrainData.detailHeight; y++) {
             if(xymaxmin[2] > y && xymaxmin[3] < y)
             {
                 for (int x = 0; x < t.terrainData.detailWidth; x++) {                
                     if(xymaxmin[0] > x && xymaxmin[1] < x)
                         map[x,y] = 1;
                 }
             }
         }
         t.terrainData.SetDetailLayer(0,0,0,map);
         t.Flush();
     




Comment
Add comment · Show 2
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 getyour411 · Sep 28, 2015 at 03:25 PM 0
Share

I think...

line 13 means "get all stuff on detailLayer 0" (that final 0 = detailLayer); if you wanted additional details you need 1,2,3...etc.

The same for SetDetailLayer, the 3rd "0" in (0,0,0...) is the Layer, if you want more details on additional layers, you need 0,0,1 0,0,2 etc.

avatar image DeadKenny getyour411 · Sep 28, 2015 at 07:23 PM 0
Share

Ah thanks, I got it working. Thanks a lot.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

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

Related Questions

Paint Terrain Texture From Vector3 List 0 Answers

Painting foliage through a script - what's wrong here? 0 Answers

Terrain heightmap isn't smooth 0 Answers

How are trees and detail meshes placed on the terrain? 1 Answer

Is there a way to create multiple terrains that use the same settings? (eg textures, grass wind settings) 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