public void SaveTexture(PaintableObject paintableObject) { brushCursor.SetActive(false); baseMaterial.mainTexture = paintableObject.GetCanvas(); canvasCam.targetTexture = paintableObject.GetBaseTex(); canvasCam.Render(); baseMaterial.mainTexture = paintableObject.GetBaseTex(); Transform brushContainer = paintableObject.GetBrushContainer(); Transform brushes = brushContainer.GetChild(0); Transform drips = brushContainer.GetChild(1); while (brushes.childCount > 0) { dotPool.FreeDot(brushes.GetChild(0).gameObject); } for (int i = 0; i < drips.childCount - 1; i++) { GameObject.Destroy(drips.GetChild(i).gameObject); } ShowCursor(); }
public void RenderCanvas(PaintableObject paintableObject, bool withCursor) { brushCursor.SetActive(false); Transform brushContainer = paintableObject.GetBrushContainer(); brushContainer.gameObject.SetActive(true); baseMaterial.mainTexture = paintableObject.GetBaseTex(); canvasCam.targetTexture = paintableObject.GetCanvas(); canvasCam.Render(); brushContainer.gameObject.SetActive(false); if (withCursor) { brushCursor.SetActive(true); baseMaterial.mainTexture = blackTex; canvasCam.targetTexture = paintableObject.m_cursorTex; canvasCam.Render(); } else { baseMaterial.mainTexture = blackTex; canvasCam.targetTexture = paintableObject.m_cursorTex; canvasCam.Render(); } }
public GameObject MakeDrip(PaintableObject paintableObject, Vector2 pos, float size) { GameObject newDrip; newDrip = GameObject.Instantiate(dripPrefab) as GameObject; SpriteRenderer rend = newDrip.GetComponentInChildren <SpriteRenderer>(); rend.color = brushColor; //Set the brush color rend.sortingOrder = paintableObject.GetBrushContainer().GetChild(0).childCount; //brushColor.a = brushSize * 2.0f; // Brushes have alpha to have a merging effect when painted over. newDrip.transform.SetParent(paintableObject.GetBrushContainer().GetChild(1), false); //brushObj.transform.parent = paintableObject.GetBrushContainer(); //Add the brush to our container to be wiped later newDrip.transform.localPosition = new Vector3(pos.x, pos.y, 0); //The position of the brush (in the UVMap) newDrip.transform.localScale = new Vector3(newDrip.transform.localScale.x * paintableObject.texScale.x, newDrip.transform.localScale.y * paintableObject.texScale.y, newDrip.transform.localScale.z); newDrip.transform.localScale *= size; return(newDrip); }
public GameObject MakeDot(PaintableObject paintableObject, Vector2 pos, float size) { GameObject brushObj; brushObj = dotPool.GetDot(); //Paint a brush SpriteRenderer rend = brushObj.GetComponent <SpriteRenderer>(); rend.color = brushColor; //Set the brush color rend.sortingOrder = paintableObject.GetBrushContainer().GetChild(0).childCount; //brushColor.a = brushSize * 2.0f; // Brushes have alpha to have a merging effect when painted over. brushObj.transform.SetParent(paintableObject.GetBrushContainer().GetChild(0), false); //brushObj.transform.parent = paintableObject.GetBrushContainer(); //Add the brush to our container to be wiped later brushObj.transform.localPosition = new Vector3(pos.x, pos.y, 0); //The position of the brush (in the UVMap) brushObj.transform.localScale = new Vector3(brushObj.transform.localScale.x * paintableObject.texScale.x, brushObj.transform.localScale.y * paintableObject.texScale.y, brushObj.transform.localScale.z); brushObj.transform.localScale *= size; return(brushObj); }