Search Unity

  1. Get the latest news, tutorials and offers directly to your inbox with our newsletters. Sign up now.
    Dismiss Notice

How to render cubes as lines?

Discussion in 'Scripting' started by olidadda, Jul 7, 2020.

  1. olidadda

    olidadda

    Joined:
    Jul 27, 2019
    Posts:
    27
    I'd like to render an 8x8 wall of cubes but I only want to render the lines that run between the cube's vertices.

    I understand I'm supposed to use Mesh.SetIndices and MeshTopology.lines but I'm rather at a loss as to how to actually start going about that as the Unity manual doesn't give any script examples.

    Any pointers are greatly appreciated!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    14,515
    The Vectrosity package on the Asset Store has a cool tool that takes an arbitrary geometric shape and replaces the edges in it with the Vectrosity line geometry:

    https://assetstore.unity.com/packages/tools/particles-effects/vectrosity-82

    Vectrosity is just overall a fantastic package, and the guy who made it regularly answers questions in the forums here.

    Alternatively you can do your own calculations and produce geometry to go between the vertices you're interested in.

    And another approach is to find or make a shader that only draws the edges of polygons... I think that's a thing but I am not sure if it could be made quad-aware or if it would put lines on every triangle, ie, two per cube face. Haven't messed much with that sorta shader.
     
unityunity