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

Users drawing a 2D map

Discussion in 'Scripting' started by zigs, Nov 29, 2012.

  1. zigs

    zigs

    Joined:
    May 27, 2009
    Posts:
    145
    Hello,

    To avoid the XY problem, here's what I'm trying to do: I want my users to have the ability to draw to a 2D map, on which the game takes place - my thought is that given that this is one of the core functionalities it would be used a lot, thus the map would be quite big and hold a lot of line strokes.

    Onto my solutions: As I see it, the best way would be to use a Texture2D, since it would aggregate the strokes into a single texture, however, draw functionality for this is still quite rough. There's only SetPixel and no DrawLine, or anything like that. I was unable to find any libraries that solves this problem. Do you know any such library, or would I just have to cook up the draw solution? (as far as I recall, drawing pretty round line ends to a pixel grid and stuff like that is actually much harder than it sounds)

    Alternative: Using a vector drawing library, such as Vectrosity. Surely Vectrosity is impressive, but would it not start to slow down given enough strokes on the screen? That would break my product badly.

    Let me know what you think.
     
  2. BPPHarv

    BPPHarv

    Joined:
    Jun 9, 2012
    Posts:
    318
  3. zigs

    zigs

    Joined:
    May 27, 2009
    Posts:
    145
    Thanks BPPHarv. Quite a JS mess, but a useful code read - could turn it into something for my purposes with a little work.

    I'm surprised that this is not an problem solved and put on the asset store..!