Hi everyone,
I’m currently working on an RTS game set during World War 1. My goal is to allow the player to create artillery fire missions (including creeping barrages) through a topographic map integrated into the UI (see image). Here’s what I’d like the player to be able to do:
- Draw multiple broken lines: (curved lines are to cumbersome to draw I think) on an existing topographic map within the UI by using the mouse.
- Display specific numerical values associated with each line.
- Allow these lines and their values to be saved and loaded (I´m sure I can handle this part myself).
- Make the lines editable, meaning that their endpoints should be adjustable.
- Highlight the lines when the mouse hovers over them.
- While it doesn’t need to be part of the UI itself, the look should fit the overall style.
- In the future, I plan to make the map zoomable.
I initially considered using the LineRenderer, but it seems to only work in World Space and not directly within the UI, unless I use a World Space Canvas (which isn’t ideal). Currently, I’m exploring Graphics scripting as it looks promising, but I wanted to gather some feedback from you regarding this approach.
I’m not necessarily asking for coding help, but rather whether my idea is feasible, what potential issues I might face, and if there are better alternatives I might not have considered.
Right now, I’m using uGUI, but I’m also considering switching to the UI Toolkit, although I’m less familiar with its capabilities in this context. I just read about the Vector Api.
Any advice, suggestions, or insights would be greatly appreciated! I think some pointing in the direction should be enough as it appears there are many elements which I not yet have experience with.
Thanks in advance!
sounds like something this package can help you do. from a quick glance it appears you can reference the points added in code so from that you can keep track of them and add other inf as you asked.
a second option is to search youtube for drawing ui lines. there are a couple of tutorials about that
https://docs.unity3d.com/Packages/com.unity.vectorgraphics@2.0/manual/index.html
Shapes is also worth looking into.
You can’t draw over (on top of) UI Toolkit elements unless you render to a RenderTexture and use that as a UI image.
Given the image you posted you want to have context-sensitive worldspace UI elements, something like Handles/Gizmos but for runtime (there are assets and repos providing this to some degree). The background image is your actual play area and not a UI (image).
Implementing an entire game using solely UI is goddamn awful. 
Even something like GameDev Tycoon isn’t UI all the way but rather context sensitive areas of the screenspace background image where, if you click on a person, it would just do a screenspace to (2d) worldspace collider check and then show the UI popup menu at that position. Much easier to do than designing a screen with areas for buttons while also accounting for different screen resolutions and such.
You can draw labels with 3D Text elements although I think they don’t scale well or don’t render crisp enough. An alternative would be to have a worldspace canvas for every individual label so you can position it where you want.
In any case you’ll likely need both, a combination of worldspace and screenspace UI. The former scales and pans with the map, the latter is fixed to the screen borders and provides context-sensitive operations. The screenspace UI provides things like mode switches, global stats, and similar. You can implement the worldspace with UGUI as UITK doesn’t support that yet, while UITK is easier and more powerful to use for screenspace.
Styling is just a matter of you applying the same or compatible styles (color, font, sizes, margins, etc) so that none of the UI feels off. In fact I would aim for distinct styles for screen and worldspace UI since they serve different purposes and the user intuitively needs to grasp which is which, if only by using a (different) outline for elements.
Thank you. I will take a look into it.
I searched a lot for it and the tutorials led me to graphics scripting. Maybe it is just that complicated in my mind and far less in reality but it feels like I have to decide now wether to use uGui oder UIToolkit. Do you know if these things are also possible with uitoolkit?
Thank you I will take a look at Shapes.
Oh I´m sorry. Please excuse me, I expressed myself unclearly. The Game itself is a 3d RTS. The Map is just an element of the ui and can be closed and opened. The topograpic map (with the heigthtlines) is an Image on an canvas.
I hope this makes things clearer. Sometimes I fail to put my ideas to text:-D
Maybe its a dumb question but can I use in UiToolkit what I create now in uGui? I´m watching some tutorials in linerendering on ui again but I hesitated from trying because it seems like a have to decide now which ui system I use.
UGUI and UITK are totally different and incompatible with each other.
You seem fixated on drawing lines over your GUI. You absolutely needn’t do this, my hunch is that it will make things even more complicated. The entire map you aim to have could be nothing but a sprite image, on which you can draw anything you wish using LineRenderer or any other means.
And then any additional UI you need could be world space canvases. You should not have a single canvas anyway for performance reasons. There’s also nothing stopping you from using worldspace UGUI and screenspace UITK together in the same project like I said.
you can have a 2D scene loaded over your 3D scene and you can fake the “UI” thing. think about skyrim map, is and UI but it also is a 3D landscape after all. so yes one should think outside the box