void DoAction(){
if (saving)
return;
Vector3 uvWorldPosition=Vector3.zero;
if(HitTestUVPosition(ref uvWorldPosition)){
GameObject brushObj;
if(mode==Painter_BrushMode.PAINT){
brushObj=(GameObject)Instantiate(Resources.Load("TexturePainter-Instances/BrushEntity")); //Paint a brush
brushObj.GetComponent<SpriteRenderer>().color=brushColor; //Set the brush color
}
else{
brushObj=(GameObject)Instantiate(Resources.Load("TexturePainter-Instances/DecalEntity")); //Paint a decal
}
brushColor.a=brushSize*2.0f; // Brushes have alpha to have a merging effect when painted over.
brushObj.transform.parent=brushContainer.transform; //Add the brush to our container to be wiped later
brushObj.transform.localPosition=uvWorldPosition; //The position of the brush (in the UVMap)
brushObj.transform.localScale=Vector3.one*brushSize;//The size of the brush
}
brushCounter++; //Add to the max brushes
if (brushCounter >= MAX_BRUSH_COUNT) { //If we reach the max brushes available, flatten the texture and clear the brushes
brushCursor.SetActive (false);
saving=true;
Invoke("SaveTexture",0.1f);
}
}
//To update at realtime the painting cursor on the mesh