Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Letting player draw to a texture and save it as a file?

Discussion in 'General Graphics' started by Mornedil, Aug 23, 2016.

  1. Mornedil

    Mornedil

    Joined:
    Feb 7, 2016
    Posts:
    19
    I'm looking for some guidance in how I would go about creating a painting feature in unity, to let players draw their own sprites / textures, which are then saved as .png files and can be loaded into the game at a later point as game resources.

    I'm still not very familiar with the workflow in Unity. I've been using GameMaker for years and know exactly how I would do it there. But.. Unity is the superior game engine, and this painting feature is only a small part of the project.
    In GameMaker, this feature would be done the following way:
    1. create a surface (image resource stored temporarily in texture memory) and set it's size
    2. set the surface as a target for any subsequent drawing or rendering
    3. execute drawing or rendering functions like normal, and things will render to the surface rather than the screen
    4. reset drawing target to the screen to prevent unwanted rendering to the surface
    5. When finished drawing, save the contents of the surface to a .png file
    I imagine the process would be entirely different in Unity, but I thought it couldn't hurt to explain the GameMaker process anyway to give an idea of the result I'm looking to achieve.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,243
    Deleted User likes this.
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,996
    Deleted User likes this.
  4. Mornedil

    Mornedil

    Joined:
    Feb 7, 2016
    Posts:
    19
    I think I forgot to mention that the painting would be done in 2D on a flat canvas, in a similar manner to how painting works in MS Paint (but with a fixed texture size), and with a similar toolset (paint brush, fill bucket, rectangular selection tool), so it might be a bit different than painting a 3D object.
    But I'll check out the links and see what I can learn from it!
     
    daneobyrd likes this.