Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

Question Can Unity draw points/filled circles?

Discussion in 'Scripting' started by felixblome, Apr 9, 2021.

  1. felixblome

    felixblome

    Joined:
    Mar 8, 2021
    Posts:
    5
    Hello there, this question is really killing me slowly.

    Basically I am searching for a solution on how to draw small points with Unity. I watched a video for Godot where the guy in the video simply calls the function "draw_circle" and that's it.

    I have done a lot of research but couldn't find any solution for Unity so far. What is especially killing me is that apparently someone in the comments applied the video to Unity, but didn't explain it.



    I basically want to achieve the exact same, but it seems like it's not possible to draw circles with Unity - or is it?
    Can anyone help me with this? That would really relief my headaches about this topic.

    Have a great day and thank your for reading!
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,992
    you can draw by setting pixels,
    https://docs.unity3d.com/ScriptReference/Texture2D.SetPixel.html
    or using gl
    https://docs.unity3d.com/ScriptReference/GL.html
    or by creating meshes
    https://docs.unity3d.com/ScriptReference/Mesh.html
    or blitting,
    https://docs.unity3d.com/ScriptReference/Graphics.Blit.html
    or using line renderer
    https://docs.unity3d.com/ScriptReference/LineRenderer.html

    there's also ready made plugins to help drawing more complex objects and lines/splines:
    https://assetstore.unity.com/packages/tools/particles-effects/vectrosity-82
    https://assetstore.unity.com/packages/tools/particles-effects/shapes-173167
    (and more in store)

    *but could also create similar hair effect with particle system (and using spawn by distance value)
     
  3. felixblome

    felixblome

    Joined:
    Mar 8, 2021
    Posts:
    5
    Thank you, these ressources already helped a bit!

    I just don't understand how to implement it the way I would like it to be. I don't find the right approach codewise, because drawing filled circles seems to be a little more difficult than expected.

    I'm sorry for asking so directly, but would it be possible to help me with an approach codewise?
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,992
    normally in unity you don't really draw pixels directly like that (its slow),
    in that example it seems to use some kind of godot canvas texture or buffer to draw into..

    anyways, to test pixel drawing,that Texture2D.SetPixel page has example to fill texture with single color,
    you could modify it so that it draws circle into that texture.
    there is some circle algorithm here:
    http://answers.unity.com/answers/591240/view.html