Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Released] Mobile Paint (with multi-touch)

Discussion in 'Assets and Asset Store' started by mgear, Aug 16, 2014.

  1. wouter_vugt

    wouter_vugt

    Joined:
    Feb 25, 2015
    Posts:
    128
    Hi I baught this asset a couple of weeks ago.

    However there is a big bug. If the app runs slow (low framerate) OR the screen resolution is very high, the paint lines becomes hard edged, instead of flowing smoothly (zig zag with hard corners). Also the paint doesn't follow the fingers correctly anymore (skips parts).
    How can I fix this, I wouldn't mind lowering the paint resolution or anything, but right now I am stuck, I cannot publish as is.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    Yes, and currently only way to decrease it is by lowering the resolution..
    (using lower res textures or adjusting resolutionScaler to 0.5 - which would be basically twice as fast = half resolution)

    You can follow the issue here to get updates on this:
    https://github.com/unitycoder/UnityMobilePaint/issues/24
     
  3. jjdomain

    jjdomain

    Joined:
    Sep 11, 2015
    Posts:
    93
    Hello,
    Following up on this feature we discussed a few months ago. The configuration option to use pan/zoom for flood fill instead of finger lining drawing.
    I believe you mentioned it was fairly easy to do and will try to get it into the next version. Has this already been implemented? I really need this function as my app centers around being able to zoom in and flood fill detailed images.
    Thanks so much.
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    I think v1.95 update had something like this (did you try the zoom-pan example scene?), unable to check right now..
     
  5. jjdomain

    jjdomain

    Joined:
    Sep 11, 2015
    Posts:
    93
    Great. Let me update and try it. thx!
     
  6. wouter_vugt

    wouter_vugt

    Joined:
    Feb 25, 2015
    Posts:
    128
    When using the eraser, I get a lot of eraser dots, I can't seem to get an actual line following my finger like when in draw mode?
    I hope this is a simple checkbox I am missing??
     
  7. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    It should be working in v1.96 - can check which version you have?
    https://github.com/unitycoder/UnityMobilePaint/issues/21

    *Also there is [x] Connect brush strokes, toggle in inspector, but that should be on by default
     
  8. wouter_vugt

    wouter_vugt

    Joined:
    Feb 25, 2015
    Posts:
    128
    Ah ok, i think i have an older version.
    I changed some things in your script though, so I hope I can switch to the new version easily.
    (auto switch from touch to mouse based on input etc)

    Also would it be possible to add more undo states?
     
    Last edited: Jul 22, 2016
  9. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    Actually multiple undos is in that new version also, seems like it wasn't mentioned in the notes though..
     
  10. rizawerx

    rizawerx

    Joined:
    May 30, 2013
    Posts:
    38
    Hi,
    I'm interested in your plugin. I want to create a game like treasure hunt, where i hide some objects under a sand, then users must 'erase' the sand to find the hidden objects. Is it possible to fill the screen with a sand image at start then use erase tool to erase the sand to find object beneath? Thanks
     
  11. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    Are the objects shown in another image, or they would be real 3D objects behind the image?

    Using the included example scenes,
    can reveal background texture by erasing top layer:
    paint-erase-top-layer.gif

    Or, erase color filled image and then see-through any objects behind
    paint-erase-texture.gif

    But if want to have texture instead of that single color, that would need to modify the script or shader a bit..
    I'll try to test it soon to see if can get it working easily (around next week..)
     
  12. rizawerx

    rizawerx

    Joined:
    May 30, 2013
    Posts:
    38
    Thanks for your feedback...I think sample #2 is close to what I need, because I need the player ( several player ) to hold the object, maybe after 2 seconds, or maybe using two hands and drag the object then drop it to center of the screen...I'll buy your plugin, looks promising...Thanks :)

    edit: I just bought it
     
  13. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    Thanks, after testing, let me know how you would prefer it to work, so i can check.
     
  14. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    Actually it should work in that "scene_MobilePaint_NewUI_EraseCanvasAlpha.scene", just assign texture into the material (and place your objects behind the canvas. Note that camera far clip is quite small on the example scene)
     
  15. rizawerx

    rizawerx

    Joined:
    May 30, 2013
    Posts:
    38
    Thanks, yes indeed it's working....I need to change the drawingPlaneCanvas layer to Ignore Raycast and also set paint layer mask to Ignore Raycast. This way I can now drag the 3d object using raycast.
    Thanks again
     
  16. rizawerx

    rizawerx

    Joined:
    May 30, 2013
    Posts:
    38
    Hi, I wonder if mobile paint supports multi touchscreen? I mean not mobile device but display monitor that capable to use touch for input. Currently I'm using DELL touchscreen, and when I tried mobile paint, I can only use one touch ( DELL is capable of 10 touch simultaneously ). When I clicked 'Enable Touch' mobile paint is not working at all...Any ideas?
     
  17. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    I don't think unity supports touchscreen same as Input.touch(), otherwise it would work..

    searching for it pretty much brings up these only,
    http://answers.unity3d.com/questions/852113/is-it-possible-to-use-a-windows-touch-screen-to-te.html
    http://touchscript.github.io/
     
  18. rizawerx

    rizawerx

    Joined:
    May 30, 2013
    Posts:
    38
    Hi again,
    I'm puzzled to have a texture erased like you have showed on example #1 on the top, but I want to behave like example #2, which revealed a 3D object..is it possible? Could you show me how? Right now I only can change the color, but can't have a texture..
    many thanks
     
  19. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    Yeah, that worked bit differently from others..
    Assign your texture into the material, which was some particle material on that example scene..
    (open example scene "scene_MobilePaint_NewUI_EraseCanvasAlpha.scene")

    But just noticed that if you change camera to Perspective, drawing has some issues..
    You might have to use 2 cameras, 1 to show perspective objects behind,
    and 1 orthographic camera for the painting scene..
     
  20. rizawerx

    rizawerx

    Joined:
    May 30, 2013
    Posts:
    38
    Thanks...after I changed texture type to Cursor, it works :)
     
  21. awawszczak

    awawszczak

    Joined:
    Dec 14, 2016
    Posts:
    1
    Hi, I'm just starting with Unity... could you tell me what scene (from examples folder) should I use to get something like you shown? I mean reveal background texture by erasing top layer.
    I need two layers with texture and I want to erase one layer.
    Thanks in advance for any help!

    SOLVED with NEW_UI_EraseCanvasAlpha.unity
     
    Last edited: Dec 15, 2016
    mgear likes this.
  22. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Hi there

    I have a case where touchscreens devices also have a mouse, is there a way for Mobile Paint to detect which input is used?

    Thanks
     
  23. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    in the Update loop it simply does this:
    Code (CSharp):
    1.            
    2. if (enableTouch)
    3.             {
    4.                 TouchPaint();
    5.             } else
    6.             {
    7.                 MousePaint();
    8.             }
    so could try what happens if you try using both, by removing/commenting those lines out:
    Code (CSharp):
    1. //            if (enableTouch)
    2. //            {
    3.                 TouchPaint();
    4. //            } else
    5. //            {
    6.                 MousePaint();
    7. //            }
     
    gegagome likes this.
  24. gegagome

    gegagome

    Joined:
    Oct 11, 2012
    Posts:
    392
    Thank you so much, it worked!

     
  25. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    This package is now free in asset store! (well as soon as the info updates).
    So if you have purchased this recently, i think unity will give refunds when requested.

    this is due to not having time to upgrade this further,
    so making it free (not deprecated in store) in case someone wants to work on it, or improve it as open-source.
     
  26. Goher1

    Goher1

    Joined:
    Nov 27, 2018
    Posts:
    1

    Just a quick question....
    Is it possible to color the texture and save its state?
    Like I have not completely colored my image and I reload the game but I don't want to color it from the start .... I want to color from the last state.
    P.s I am working on a kids coloring game using MP and want to add this functionality.
    Looking forward to your reply.
     
  27. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    hmm.. no, but maybe 2 options:
    - save the image on exit, and then use that as a drawing canvas..
    - or hacky way, save each color and click (and then redo all those actions when coming back)
     
  28. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    Hello,
    I used this asset. but when i m changes brush size into script it not set.
    i m used script method like( mobilePaint.SetBrushSize(20);), but it can't happened.
     
  29. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    cannot test it at the moment but that should be it..
    does it work normally if you change size from the example ui? (its using the same code)
     
  30. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    I 'm set it ToggleBrushModeUI.cs script.

    public void SetModepencile()
    {
    if (GetComponent<Toggle>().isOn)
    {
    mobilePaint.SetDrawModeBrush();
    mobilePaint.SetBrushSize(3);

    }

    }
    and also change it mobilepaint.cs script variable like
    brushSize = 3
    brushSizeMin = 3
    brushSizeMax = 64; // default max brush size

    but at that runtime i am starting to drawing line .it draw some time big and some time small.not drawing with perfect edges using mouse and touch.
     
  31. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
  32. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    In Default brush size it working perfectly but when im choose custom brush i can't change brush size.
    plz help me im stuck here.
    waiting for your positive responce .
    Thanks IN AD
     
  33. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    payalzariya07 likes this.
  34. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    Hello,

    How to draw pattern texture with color ? using mobile paint asset.

    And I am trying to draw brush like spray in game. can anyone give suggestion.

    plz help me im waiting the answer.

    Thanks in AD
     
    Last edited: Apr 12, 2019
  35. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    pattern with custom colors,
    could modify DrawPatternCircle(int x, int y), so that instead of using original pattern colors,
    it would use your custom color for RGB values, while keeping the pattern alpha (cant remember if it did support alpha though)

    for (random) spray, i guess could try having your own spray brush frames and randomly change them all the time with script.. (not sure if too slow)

    or using script to call Draw(x,y) manually many times to random positions..

    or creating your own new drawmode, and modify the drawcircle method to draw spray,
    similar to https://stackoverflow.com/a/11938713/5452781 (basically fill only random pixels from the circle)
     
  36. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    I am modify it but nothing happened.
    what i can change in this code can you tell me.







    public void DrawPatternCircle(int x, int y)
    {


    int pixel = 0;
    for (int i = 0; i < brushSizeX4; i++)
    {
    int tx = (i % brushSizeX1) - brushSize;
    int ty = (i / brushSizeX1) - brushSize;

    if (tx * tx + ty * ty > brushSizeXbrushSize) continue;
    if (x + tx < 0 || y + ty < 0 || x + tx >= texWidth || y + ty >= texHeight) continue; // temporary fix for corner painting

    pixel = (texWidth * (y + ty) + x + tx) << 2;

    //if (useAdditiveColors)
    //{
    // additive over white also
    if (!useLockArea || (useLockArea && lockMaskPixels[pixel] == 1))
    {

    // TODO: take pattern texture as paint color

    Color32 patternColor = new Color(x, y, 0, 1);

    pixels[pixel] = (byte)Mathf.Lerp(pixels[pixel], patternColor.r, patternColor.b / 255f * brushAlphaStrength);
    pixels[pixel + 1] = (byte)Mathf.Lerp(pixels[pixel + 1], patternColor.g, patternColor.b / 255f * brushAlphaStrength);
    pixels[pixel + 2] = (byte)Mathf.Lerp(pixels[pixel + 2], patternColor.b, patternColor.b / 255f * brushAlphaStrength);
    pixels[pixel + 3] = (byte)Mathf.Lerp(pixels[pixel + 3], patternColor.b, patternColor.b / 255 * brushAlphaStrength);
    // if (!useLockArea || (useLockArea && lockMaskPixels[pixel] == 1))
    //{
    // pixels[pixel] = paintColor.r;
    // pixels[pixel + 1] = paintColor.g;
    // pixels[pixel + 2] = paintColor.b;
    // pixels[pixel + 3] = paintColor.a;
    //}
    // }
    //}

    //}else{ // no additive, just paint my colors

    //if (!useLockArea || (useLockArea && lockMaskPixels[pixel] == 1))
    //{
    float yy = Mathf.Repeat(y + ty, customPatternWidth);
    float xx = Mathf.Repeat(x + tx, customPatternWidth);
    int pixel2 = (int)Mathf.Repeat((customPatternWidth * xx + yy) * 4, patternBrushBytes.Length);

    pixels[pixel] = patternBrushBytes[pixel2];
    pixels[pixel + 1] = patternBrushBytes[pixel2 + 1];
    pixels[pixel + 2] = patternBrushBytes[pixel2 + 2];
    pixels[pixel + 3] = patternBrushBytes[pixel2 + 3];
    }

    //} // if additive
    } // for area
    }
     
  37. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    in this part it takes pixels from patterns brush (patternBrushBytes[9) , and assigns into drawing (pixels[])
    Code (CSharp):
    1. pixels[pixel] = patternBrushBytes[pixel2];
    2. pixels[pixel + 1] = patternBrushBytes[pixel2 + 1];
    3. pixels[pixel + 2] = patternBrushBytes[pixel2 + 2];
    4. pixels[pixel + 3] = patternBrushBytes[pixel2 + 3];
    so for a quick test, remove those patternBrushBytes[pixel2] parts and put some fixed values
     
  38. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    in this line

    pixels[pixel] = patternBrushBytes[3];

    i am put value but nothing happened.
     
  39. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    test all those 3 lines
    pixels[pixel] = 255
    pixels[pixel + 1] = 255
    pixels[pixel + 2] = 0
    pixels[pixel + 3] = patternBrushBytes[pixel2 + 3]; //maybe this is alpha, or the first one
     
  40. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    Using This image(1) I am trying to draw random circle with user choose color Look like image(2)
     

    Attached Files:

    Last edited: Apr 12, 2019
  41. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    How to draw simple circle image with repeat random scale using custom brush.

    look like below image.

    plz help me im stuck here.
    waiting for your positive responce .

    Thanks in AD.
     

    Attached Files:

  42. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    hello ,

    can anyone tell me in mobile paint assets how to repeat selected brush texture with some random distance, random scale.
     
  43. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    Hello ,

    I am trying to set custom brush repeat it texture continue. But it can't happened .anyone know how to set repeat texture in drawing using this assets.

    plz anyone can help me.

    Thanks ad.
     
  44. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    I am using this Assets But i have problem for painting. When clear canvas image after drawing it will start drawing the last position for click. I am removing this feature. can you help me how to stop to drawing last position.
     
  45. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    looks like i didnt get notifcations for a while here..

    i'm guessing it appears if [x] connect lines is enabled?
    could try setting wentOutside to true when clearing image?
    or if not working, then need to disable/skip what happens when connectBrushStokes is enabled, on first click after clear image..
     
  46. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    do you mean similar to drawing with pattern texture?
     
  47. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    ok i see you probably mean this in previous question.

    would need to call the DrawCustomBrush() manually, with random positions around mouse cursor or so..

    Custom brush scaling is not supported, so theres 2 options
    - add multiple versions (with different sizes) of your custom brush and splat those randomly
    - add texture scaling to custom brushes (but probably too slow in the cpu, although you could do that once at start and cache them)
     
  48. payalzariya07

    payalzariya07

    Joined:
    Oct 5, 2018
    Posts:
    85
    Thanks for giving answer.

    I am solve it.
     
  49. Jael-Acaxa

    Jael-Acaxa

    Joined:
    Aug 19, 2019
    Posts:
    9
    Hello, I don't know if this thread is still receiving updates, but I would like to know about how I can implement a function.

    I want to touch on the screen and the brush size will increase with the time I hold it down. I thought of doing this by increasing a texture size but i would like to know if there's another way.

    And also know how I can do to decrease lag when i touch the screen.

    Thank you: D
     
  50. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,350
    check BrushSizeUI.cs (that handles the brush size normally),
    so you can call mobilePaint.SetBrushSize(yoursize) to adjust size.
    (custom brushes doesnt support sizes, so you would need to create texture resizer for that)