Created
August 7, 2012 23:19
-
-
Save haikusw/3290457 to your computer and use it in GitHub Desktop.
some snippets of a routine to create a dynamically drawn on 2d texture in unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dynamic drawing to a texture in Unity3d basic. This is not complete working code but pieces cut out of working code so you'll have to look up the documentation for the functions called to get specific parameters and such. | |
static function CreateFooTexture ( ... ) | |
{ | |
// create texture: | |
var tex : Texture2D = new Texture2D(512, 512, TextureFormat.ARGB32, false); | |
// get the pixels | |
var cols : Color[] = tex.GetPixels( ... ); | |
// set the specific color values in cols here based on whatever your algorithm is: | |
... | |
// things like: cols[rowbytes*ap.y + ap.x] = color; | |
... | |
// then update the texture | |
tex.SetPixels( ... , ..., rowbytes, rowbytes, cols ); | |
tex.Apply(); | |
// set any texture properties you need | |
tex.wrapMode = TextureWrapMode.Clamp; | |
return tex; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment