Search Unity

Preventing modifications to textures when using SetPixel

Discussion in 'Scripting' started by fatso, Nov 16, 2007.

  1. fatso

    fatso

    Joined:
    Jul 21, 2006
    Posts:
    51
    My game dynamically updates splatmaps associated with a terrain, but I've found these changes are permanently saved back to the texture. While this would be really useful if I was using this to extend the editor, it's less than desirable to have my missile scorch damage etched onto the terrain forever after a quick playtest :)

    I could potentially duplicate the texture in the script before the game began, but there isn't a programmatic way to apply a new splatmap texture to a terrain at present (and in any case, this seems like a hack). I also checked out the HideFlags, but these don't seem to do what I want.

    Any tips? [Edit: have the post a better title]
     
  2. AaronC

    AaronC

    Joined:
    Mar 6, 2006
    Posts:
    3,552
    Hey Hayden. Eric and Yoggy posted really cool packages here. I used Erics as reference for my project and he clones a texture at runtime, which achieves what I think your after. Read his comments in his script.

    http://forum.unity3d.com/viewtopic.php?t=5790

    Cheers
    AC
     
  3. fatso

    fatso

    Joined:
    Jul 21, 2006
    Posts:
    51
    Thanks, there's some good thoughts in that thread!

    That said, terrain is a little different, because all the properties aren't accessible to scripts yet. Still, I'll work something out.