Search Unity

How to draw a line using X, Y, Z coordinates from a csv or txt file?

Discussion in 'Editor & General Support' started by andre_anastacio, Mar 14, 2019.

  1. andre_anastacio

    andre_anastacio

    Joined:
    Feb 21, 2019
    Posts:
    3
    I'm new on Unity and I'm having difficulty to drawing a line on the screen using the X, Y, Z coordinates of a CSV or TXT file, like a data visualization. I tried with the line render and also with swipe trail, but I could not. Thanks for your help.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    You need to separate your problems into pieces. Drawing a line from CSV or TXT is not a single issue, and you'll never figure it out if you treat it as one.

    1) Learn how to use the line renderer on its own
    2) Learn how to read from text files
    3) Learn how to convert the strings from text files into variable types useful with the line renderer
    4) Tie it all together
     
    andre_anastacio and fffMalzbier like this.
  3. andre_anastacio

    andre_anastacio

    Joined:
    Feb 21, 2019
    Posts:
    3
    got it! Sorry for not being specific in the question. I am searching just this item "3) Learn how to convert the strings from text files into variable types useful with the line renderer". but I'm not finding solutions. can you indicate a way?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I usually use Parse, but there's more methods, mostly documented below.

    https://docs.microsoft.com/en-us/do...ide/types/how-to-convert-a-string-to-a-number

    For things like vector3's you'd convert the 3 floats from strings individually then combine them into a single vector3.
     
    andre_anastacio likes this.