Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

How save terrain height and splat to file use c# ?

Discussion in 'Scripting' started by DarkDeivel, Jan 14, 2021.

  1. DarkDeivel

    DarkDeivel

    Joined:
    Aug 31, 2016
    Posts:
    76
    Hello everybody!

    I am making a level editor for the game. I was able to implement height change and texture painting at runtime.

    Now the question is how to save the created terrain to a file?

    The terrain itself has Import / Export Raw heightmap buttons. How can I implement this method via c #?

    Maybe there are other ways? Thanks for answers.
     
  2. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,292
    If your only goal is to make a level editor wouldn't it make more sense to export the entire terrain and re-import that? Or is there something specific you're need with the height map and texture?
     
  3. DarkDeivel

    DarkDeivel

    Joined:
    Aug 31, 2016
    Posts:
    76
    Of course that would be cool, but how can you export a entire terrain?
     
  4. Lethn

    Lethn

    Joined:
    May 18, 2015
    Posts:
    1,292
  5. DarkDeivel

    DarkDeivel

    Joined:
    Aug 31, 2016
    Posts:
    76
  6. seejayjames

    seejayjames

    Joined:
    Jan 28, 2013
    Posts:
    345
    Do you have a 2D array of all the terrain's heights? You can save that array to a file and reload it. Though the serialization approach might do some of this automatically, not sure.
     
  7. DarkDeivel

    DarkDeivel

    Joined:
    Aug 31, 2016
    Posts:
    76
    I solved the problem using serialization, which was given in the link above.
     
    seejayjames likes this.
unityunity