Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
1
Question by devilkkw · Mar 17, 2010 at 11:55 PM · terrainlayersgrassdetail

Can I modify grass or details on the terrain at runtime?

Can i have opportunity to remove a type of grasslayer via scrpt? for example when my cube collide on a selected type of grass,the grass die.Is it possible?

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 Henck · Jun 27, 2013 at 12:41 PM 0
Share

Here's an article about removing grass from a Unity terrain and its limitations: http://bit.ly/1aQb0W9

2 Replies

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

Answer by duck · Mar 18, 2010 at 10:50 AM

You can use these (undocumented) commands to read and write the terrain detail layers:

// read all detail layers into a 3D int array: int numDetails = terrainData.detailPrototypes.Length; int [,,] detailMapData = new int[terrainData.detailWidth, terrainData.detailHeight, numDetails]; for (int layerNum=0; layerNum < numDetails; layerNum++) { int[,] detailLayer = terrainData.GetDetailLayer(int x, int y, int width, int height, int layerNum); }

// write all detail data to terrain data: for (int n = 0; n < detailMapData.Length; n++) { terrainData.SetDetailLayer(0, 0, n, detailMapData[n]); }

So, using the above scripts, you would read the layers, edit the values in the array relating to the details at a particular area, and then write the details back to the terrainData.

Because these functions are undocumented, any future updates of the unity engine might change or remove these functions from the API. This means your project may not work in future versions of the Unity editor, and webplayer builds may not work with future versions of the plugin.

Comment
Add comment · Show 1 · 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 Headrush95 · Jul 18, 2020 at 11:12 PM 0
Share

i made a script that alters the materials emission of my grass prefab, i have added it as a detail mesh and i have tried everything to try and get the material to update.

now let me explain in more detail, my material is a HDRP lit, my script compares the distance between the player and the grass transforms, if it is less than the specified range then the materials emission changes, this all works, specifically it works when placing the prefab in the scene, but not when painting the prefab on the terrain, i have the nature render er Asset pack to render the materials, and have no idea how to go about making the material in my prefab, in my terrain detailmesh update.

avatar image
0
Best Answer

Answer by runevision · Mar 18, 2010 at 10:51 AM

I assume you are talking about grass on the built-in terrains in Unity.

You can modify the terrain at runtime. See this Q&A:
http://answers.unity3d.com/questions/2224/just-how-malleable-are-terrains-really

You can use that functionality to alter where the grass is on a terrain.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How can I automatically place grass and other details on my terrain to correspond with the splatmap? 5 Answers

Some questions about the choice between terrain editor's built in in unity 3D or make all whitin a 3rd partyy program like 3DSMAX. 0 Answers

Terrain texture with alpha? 1 Answer

Specify detail density and detail distance PER grass texture? 0 Answers

Flickering grass on terrain 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