- Home /
How to draw a sort of "debug overlay circle" similar to Cinemachine camera setups.
In short, I'm hoping to draw debug circles like this on my game screen:
I know that something like this is possible, since Cinemachine uses a similar system to define follow bounds, etc. I haven't really messed with making editor scripts, so I don't know where to start, and I've tried googling it, but can't find anything for sort of "debug overlays" like this. Any help would be appreciated!
Answer by VoltzerDev · Jun 09, 2020 at 07:46 PM
Hey! You can use UIExtensions Package to create the circles. It is not only made for debugging, you can also use it for other UI elements and it's really easy to use. It also scales with any resolution.
Go to the Window -> Package Manager
Select "All Packages" and search for Unity UI Extensions and download an import the package
To make the circles click on the canvas and create the desired UI element Here you can see where to find UICircle.
Hope this helps! On my youtube channel, you can see how it looks like in my game: https://www.youtube.com/channel/UCq-S83BCJL3r9W9t3V9aYdA
Answer by ArseneySorokin · Jun 09, 2020 at 08:08 AM
Gizmos are drawn in the scene view, as far as I know, there is no way to get them into the game view.
I am aware of Gizmos and have used them quite a bit, what I am wondering is if there is a sort of UI overlay equivalent. Gizmos are drawn in world space, which doesn't help me debug UI distances in the game view.
Answer by BastianUrbach · Jun 09, 2020 at 04:54 PM
You could use GUI.DrawTexture in a script with the [ExecuteAlways] attribute to make it visible in the game view even when the game isn't running. That wouldn't give you any shapes though, just the ability to draw textures (which you can modify by script but that's not quite as convenient as Gizmos are).
Answer by mstevenson · Oct 16, 2021 at 11:55 PM
Unity offers source code for the Cinemachine game view overlay:
It looks like they call GUI.DrawTexture
during OnGUI()
as BastianUrbach suggests
Your answer
Follow this Question
Related Questions
Get value from dynamically created EditorGUILayout.IntField 1 Answer
Custom Inspector Color Spacer 1 Answer
Track when the value is changed and get it 0 Answers
Is there an event to catch on Open a scene 0 Answers
Custom Inspector for a List ? 2 Answers