Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Lines, arcs or circles?

Discussion in 'Editor & General Support' started by bigkahuna, Feb 18, 2008.

  1. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I'm trying to think of a way to create a grid-overlay for a HUD map view that would be scalable (so I can zoom the map view without the grid becoming thicker). A bitmap would be the easiest solution, but it isn't scalable. I'm guessing the only way to accomplish this is with LineRender, but to create an arc or circle with LineRender might not look very smooth. Plus I'd have to scale the thickness as the view is zoomed in or out... anyone have any better ideas?
     
  2. NCarter

    NCarter

    Joined:
    Sep 3, 2005
    Posts:
    686
    If you want to display custom geometry of any kind, you should look at the Mesh editing API. That will enable you to draw your arcs as smoothly as you like and to scale them according to the zoom level as necessary, although you'll have to do all the arithmetic yourself when you position the vertices.

    If you have Pro, you could also draw whatever you want with the GL class. It will probably be a bit easier than setting up the Mesh API, but the cost of drawing everything in immediate mode is likely to become a problem if you have a lot of vertices to process. The GL class is usually only a better idea if you have a small amount of geometry to draw and/or it all changes dramatically every frame.
     
  3. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Thanks Neil. What I'd really like is some way to do this in UnityGUI, but AFAIK that isn't possible...
     
  4. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Draw the grid into a Texture2D using SetPixels? You would need your own line/arc drawing routines, of course.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Marble did the scalable grid overlay thing here (for his Heaven and Earth game). That's using the mesh interface...works pretty well.

    --Eric
     
  6. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Ahhh... that's the ticket! Thanks Eric and everyone for some great ideas.