Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Mass Assign Terrain Textures

Discussion in 'Scripting' started by sterynkng14, May 22, 2015.

  1. sterynkng14

    sterynkng14

    Joined:
    Sep 19, 2013
    Posts:
    36
    After searching for a while, I've come up with nothing. So I am wondering, is there a way to access the terrain textures from script so that they can be changed through script?
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  3. sterynkng14

    sterynkng14

    Joined:
    Sep 19, 2013
    Posts:
    36
    Hmmm... not exactly what I need. Heres my case, I have a terrain made up of several tiles. I am trying to manage those tile terrains more efficiently using an editor window so I am trying to figure out how to change the settings and textures of each.
     
  4. ThatGuyFromTheWeb

    ThatGuyFromTheWeb

    Joined:
    Jan 23, 2014
    Posts:
    29
    I assume each 'tile' is a separate terrain object? Then you can do that through the TerrainData-Class LeftyRighty linked you. Each unity terrain has an instance of terraindata controlling how the terrain looks, what trees and textures it uses and offers access to height-data and other things. This class allows you to set most of the settings in code. You should be aware that changing some of them will result in a loss of the data your terrain has.

    If you just want to access the splat texture definitions (the texture slots you have in the standard editor to add, edit or delete textures) you should check out the splatPrototypes property. Also be warned: Writing an editor for multi-terrain editing seems not the easiest thing one could do.
     
    sterynkng14 likes this.
  5. sterynkng14

    sterynkng14

    Joined:
    Sep 19, 2013
    Posts:
    36
    Thank you, I believe the splatPrototypes is exactly what I was looking for. Guess I had overlooked it. The editor isn't the easiest, but it is a challenge and challenges teach you new things so why not? haha
     
  6. sterynkng14

    sterynkng14

    Joined:
    Sep 19, 2013
    Posts:
    36
    splatPrototypes is exactly what I needed. Now I can manage the textures for each tile with one setting. Thank you.