Tool to add drawable RawImage for Unity (using only GPU to improve performance).
You can add the package with the new Package Manager from the window menu using the repository address https://github.com/Quokka-Indie-Studio/Drawing-UI-Texture-package.git. (Window -> Package Manager)
Or add the line below in the dependencies block inside the manifest.json
{
"dependencies":
{
"com.quokkaindiestudio.drawinguitexture":"https://github.com/Quokka-Indie-Studio/Drawing-UI-Texture-package.git"
}
}
First create a new canvas in World Space or in Screen Space - Camera.
Doesn't work with canvas in Screen Space - Overlay render mode.
Add the Draw texture from hiearchy window.
- Brushes - To change brush texture.
- Size - To change brush size.
- Opacity - To change brush opacity.
- Color - To change brush color.
- Type - To change brush mode.
- Draw on tranparency - To allow brush application on alpha texture.
- Resolution - To change image resolution in the Start function.
The different types of brush are pretty straight forward.
- None - To apply color
- Eraser - To erase the drawing
- Negative - To change image color in negative color.
- Additive - To apply color additively.
- Multiply - To multiply color.
- Subtract Alpha - To reduce alpha.
- Add Alpha - To add alpha.
using LS.DrawTexture.Runtime;
private void MyFunction()
{
DrawTextureUI myDrawTexture = GameObject.FindObjectOfType<DrawTextureUI>();
//To get current texture
Texture2D myTexture = myDrawTexture.GetTexture2D();
//To reset texture
myDrawTexture.Clear();
//To change brush texture
myDrawTexture.IdTexture = 0;
//To change brush size
myDrawTexture.Size = 0.5f;
//To change brush Opacity
myDrawTexture.Opacity = 0.01f;
//To change brush mode
myDrawTexture.Type = DrawTextureUI.BrushType.none;
//To change brush color
myDrawTexture.Color = new Color(1.0f,1.0f,1.0f,1.0f);
//To allow brush application on alpha texture
myDrawTexture.DrawOnTransparency = true;
}
To add a new brush, you have to do a Resources folder and inside it, add the Brushes folder.
The texture must have a white border and the width and height texture have to be the same (for instance 512x512).
WARNING do not generate mip maps.
- Clear - To reset texture.
- Save - To save current texture.
Save the current texture in the Textures Saved folder (Assets/Textures Saved/)
After that you have to refresh files to see the folder.
WARNING do not refresh files while the scene is playing.
- Add more modes