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
-1
Question by leonida · Jul 06, 2012 at 04:39 PM · texturetreegrass

change grass - tree texture at runtime

hello, which method to use to change the textures of trees and grass at runtime? is it possible?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by flaviusxvii · Jul 06, 2012 at 04:51 PM

Asked and answered literally dozens of times. Google "unity3d change texture".

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 leonida · Jul 06, 2012 at 05:00 PM 0
Share

I know how to change texture on a normal object.

example:

var mytexture : Texture;

var myobj : GameObject;

function Update(){

       myobj.renderer.material.mainTexture = mytexture;
       
       }

Does NOT work on terrain.

avatar image flaviusxvii · Jul 06, 2012 at 08:28 PM 0
Share

Your question was about grass and trees. You said NOTHING about terrain.

avatar image leonida · Jul 07, 2012 at 08:08 AM 0
Share

I meant objects of terrain, just like grass and trees

avatar image
0

Answer by jc_lvngstn · Jul 06, 2012 at 07:11 PM

Seems like you would have to update the original prefab of the tree, then tell the terrain to refresh. From memory, I think this involves a voodoo mix of

Reset the terrain heights. I normally set the heights giving it an empty array of height values. No heights are changed, but it forces the terrain to refresh. Partially. disabling and reenabling the terrain collider. Again...this is from memory. I don't have the exact sequence of steps in front of me.

I normally have to do something like this when I remove a tree, and need to update the terrain collider. I believe I have an answer here somewhere that has more info.

But, I can't guarantee that you can update the prefab on the fly like that, and the terrain automatically take notice. Good luck, if you figure it out please post your findings :) Sounds like you are changing things based on weather or season? If that is the case, you -could- create different prefabs for each tree, depending on the season, and tell the terrain to use those instead. I know for a fact that that would work!

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 leonida · Jul 07, 2012 at 08:07 AM 0
Share

thank you! a code example?

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

grass with particle system 1 Answer

Why are textures disappearing when camera gets close? 1 Answer

Grass Textures of Terrain changing colors dinamically 2 Answers

Brush Size and Tree Deletion problems 0 Answers

My grass looks really weird. 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