Search Unity

Display a list of points

Discussion in 'Scripting' started by petrasvestartas, Aug 19, 2019.

  1. petrasvestartas

    petrasvestartas

    Joined:
    Aug 14, 2019
    Posts:
    13
    Hi,

    In the C# Custom script I have a list of points.

    How can I display a list of points to Unity?

    I tried to create a list of cubes, but the way of displaying a list of points by adding cubes simply feels wrong. I know that there are very good Unity plugins to display large pointclouds, but is there any simple way to display a list of points instead of creating those cubes as certainly this display method is super slow. I would really like to avoid downloading external plugins.

    foreach (Vector3 v in vectors)
    {

    GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
    cube.transform.position = v;
    cube.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
    cube.GetComponent<Renderer>().material.color = colors[k];

    }
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,440
  3. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    While mgear's answer is correct in principle, it's also very brief.

    Instead of using cubes, you can (which is more what particles do) use small quads that are always oriented so that they face the camera, and use a small texture that is simply a dot. Things that work like this in Unity are sometimes also called 'billboards', and unity provides special support for these (although you can get by without the full billboard functionality dscribed in the manual - all you need is to orient the quad to the camera)

    I think that after reading up on Quads and Billboards, you are well on your way to implement a nice, workable solution.