Marek Buchtela
Marek Buchtela

Reputation: 1003

Drawing in Unity using C#

I currently have a WinForms C# application. I have a .txt file with GPS coordinates of some points (borders of buildings, roads etc.), and using Graphics.FillPolygon method in System.Drawing I am drawing these on a Panel. However, I got an idea that for what I am trying to do (it basically is a 2D game), a Unity 2D project would be more suitable and easy to use (mainly because of easier view handling using the cameras). However, I don't know how to do this drawing in it. I just need to somehow get these coordinates drawn in Unity, but I don't know how to do it.

Note: I already have some minor expirience with 3D in Unity, but I am a total newbie to 2D. Thanks

Upvotes: 3

Views: 6850

Answers (1)

Krzysztof Bociurko
Krzysztof Bociurko

Reputation: 4662

There is no GDI/canvas implementation built into Unity. Drawing these in rastered 2D would be quite hard in Unity (basically putpixel level, or finding some third party library).

You have an alternative, though - you can draw these shapes in 3D, ignoring the third dimension. You have a few methods for this:

  1. Line renderers - this one will be the easiest, but forget about anything else than just drawing the outline, no fill etc.

  2. Make your own mesh - This will let you use the geometry with your scene. It's an retained mode API (you init your geometry once)

  3. Use the GL namespace - This will be only rendered on the screen, no interaction with the scene. It's an immidiate mode API (draw everything on every frame)

Upvotes: 5

Related Questions