Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

read csv file in unity c#

Discussion in 'Editor & General Support' started by ano99, Jul 21, 2019.

  1. ano99

    ano99

    Joined:
    Jul 16, 2019
    Posts:
    3
    hi !
    I read csv file to transform animation in x y z .
    And my code Like this :
    -----------------------------------------------------------------------------------------------------------
    Code (CSharp):
    1.  
    2. public TextAsset coordinates;
    3. public float moveSpeed;
    4. // public float MoveSpeed =
    5. string[] coordinatesArray;
    6. int currentPointIndex = 1;
    7. Vector3 destinationVector;
    8. Quaternion lol;
    9.  
    10. void Start()
    11. {
    12. coordinatesArray = coordinates.text.Split(new char[] { '\n' });
    13. }
    14. void Update()
    15. {
    16.  
    17. if (destinationVector == null || transform.position == destinationVector)
    18. {
    19. currentPointIndex = currentPointIndex < coordinatesArray.Length - 1 ? currentPointIndex + 1: 1;
    20. if (!string.IsNullOrWhiteSpace(coordinatesArray[currentPointIndex]))
    21. {
    22.  
    23. string[] xyz = coordinatesArray[currentPointIndex].Split(new char[] { ',' });
    24. destinationVector = new Vector3(float.Parse(xyz[0]), float.Parse(xyz[2]) * -1, float.Parse(xyz[1]));
    25. transform.rotation = Quaternion.Euler(float.Parse(xyz[3]), float.Parse(xyz[5]), float.Parse(xyz[4]));
    26. /* float terrainWhereWeAre = Terrain.activeTerrain.SampleHeight(transform.position);
    27. if(terrainWhereWeAre >-123.0f)
    28. {
    29. transform.position = new Vector3(transform.position.x, terrainWhereWeAre, transform.position.z);
    30. }*/
    31. }
    32. }
    33. else
    34. {
    35. transform.position = Vector3.MoveTowards(transform.localPosition, destinationVector, Time.deltaTime * moveSpeed);
    36. }
    37. }
    38.  
    -----------------------------------------------------------------------------------------------------
    so I want to skip 10 line in csv and i don't know how can I do it ?
    and plz help me >> <<
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,754
    You probably want increase currentPointIndex by 10.