Page with transparent region

For example you want to make the app where you want to paint the t-shirt, so you don't need to show anything exept of t-shirt, and you don't want to allow user paint anywhere outside of it.

There is no built in support for this in paintcraft so you need to code a bit.

Step by step guide

  1. Change default background color to transparent (see black line below- which indicate that color has alpha=0)

  2. Open CanvasController.cs in editor and make sure that DoSaveChangesToDisk and LoadFromDiskOrClear looks like this

  3. IEnumerator DoSaveChangesToDisk()
    {
    yield return new WaitForEndOfFrame();
    RenderTexture tmp = RenderTexture.active;
    RenderTexture.active = BackLayerController.RenderTexture;
    TmpTexture2D.ReadPixels(new Rect(0,0,BackLayerController.RenderTexture.width, BackLayerController.RenderTexture.height),0,0,false );
    File.WriteAllBytes(SaveFilePath, TmpTexture2D.EncodeToPNG());
    RenderTexture downscaledRT = RenderTexture.GetTemporary(440, 330);
    Graphics.Blit(CanvasCameraController.Camera.targetTexture, downscaledRT);
    RenderTexture.active = downscaledRT;
    TmpTextureIcon2D.ReadPixels(new Rect(0, 0, 440, 330), 0, 0, false);
    File.WriteAllBytes(PageConfig.IconSavePath, TmpTextureIcon2D.EncodeToPNG());
    RenderTexture.ReleaseTemporary(downscaledRT);
    RenderTexture.active = tmp;
    }
    public bool LoadFromDiskOrClear()
    {
    if (File.Exists(SaveFilePath) && !string.IsNullOrEmpty(PageConfig.name))
    {
    if (TmpTexture2D.LoadImage(File.ReadAllBytes(SaveFilePath)))
    {
    CanvasCameraController.Camera.targetTexture.DiscardContents();
    Graphics.Blit(TmpTexture2D, CanvasCameraController.Camera.targetTexture, new Material(Shader.Find("Unlit/Transparent")));
    SetupTmpTextureSize();
    return true;
    }
    }
    ClearCanvas();
    return false;
    }
  4. In region file of your page config region which you don't want to paint must be transparent, another regions the same random color as usual

  5. You probably want to make start_image as well, so when your image start you will able to automatically show internal painted regions see images below. it has 2 files, one as default image, another is region file with transparent region dont forget to update your page config and include star image there

  6. You have to Use advanced eraser instead of normal. so when you will erase image it will erase in to default image rather than transparent color.