Search Unity

Player Made Graphics Help

Discussion in 'General Discussion' started by justinbfraser314, Aug 5, 2019.

  1. justinbfraser314

    justinbfraser314

    Joined:
    Jun 24, 2019
    Posts:
    4
    I have been transitioning two of my old projects from other engines to Unity recently and I am not sure where to start on one aspect of one of them. I have a game where your character is tagging (spray painting graffiti) all over a school. This tag is designed by the player in a custom editor.



    I accomplished this by taking a screenshot of the area where it showed the tag and over-writing the image for the general tag with the screen shot. I am not above doing this the same janky way, just I have no idea where to even begin. I am not looking for line-by-line scripting, just some general advice on how to begin because as I can tell, Unity's screen capture function won't really work for me.
     

    Attached Files:

  2. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    You could store this custom image from a player into a byte[] array if you read the custom image bytes.
    Then make a Texture2D from the byte[] array. And then make it into a sprite. (Might can skip the Texture2D) part for that, haven't messed with sprites all to much. But essentially just capture the bytes from the image and figure out how to get it into the sprite.
     
    Ryiah and MadeFromPolygons like this.
  3. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    Or a less performant but probably easier way is to just store each pixels color as an array of colors color[] and then recreate your texture from that. Your editor is pixel by pixel so this would be relatively easy and creating a texture2d from a set of colors is trivial.

    This way you could just call setpixels using the array of colors:

    https://docs.unity3d.com/ScriptReference/Texture2D.SetPixels.html
     
    SparrowGS, Ryiah and N1warhead like this.
  4. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Yeah that also works.