- Home /
Question by
Alexandra · May 05, 2011 at 02:22 PM ·
javascripttexturedrawing
I want draw a line on sphere's texture
But I don't know how. Or draw a bold point where I touch by mouse.
Comment
Answer by Alexandra · May 15, 2011 at 04:13 PM
var r=5;
var texture : Texture2D ;
function Start () { renderer.material.mainTexture = texture; }
function OnMouseDown () {
if(Input.GetMouseButton(0)) { for (var y = Input.mousePosition.y-r;y<=Input.mousePosition.y+r;y++) { for (var x = Input.mousePosition.x-r;x<=Input.mousePosition.x+r;x++) { texture.SetPixel(x, y, Color (1, 0, 0, 1));
}
} texture.Apply();
}
}