• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by benfattino · May 04, 2011 at 09:44 AM · vector3txt

Vector3 array from .txt

How I create a Vector3 array (Vector3(0,0,0),ecc) to use with GL.lines and Vectrosity command starting from a external .txt file with a list of point coordinates (0,2,2,2,ecc...)?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jean-Fabre · May 04, 2011 at 10:00 AM 1
Share

If you could provide the exact format, it's then possible to write a script that properly parse your txt file.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by CHPedersen · May 04, 2011 at 09:52 AM

That depends entirely on how data is formatted in that text file. :)

Is just comma-separated numbers? So Vector1 consists of the first three numbers in the file, and Vector2 consists of the next three numbers, and so on?

In any case, you're probably going to need to parse the text using String.Split after you've loaded it into your program with a System.IO.TextReader.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image benfattino · May 04, 2011 at 05:58 PM 0
Share

Can you help me with code example? .txt file are similar to 0,0,0,ecc...

avatar image CHPedersen · May 05, 2011 at 06:27 AM 0
Share

Yes, but you haven't answered my question about what those numbers correspond to. 0,0,0 = what? Is that the first vector's (x,y,z), or is that the x coordinate of the first 3 vectors?

avatar image benfattino · May 13, 2012 at 11:15 AM 0
Share

example of txt: 0,0,0, //x,y,z, of first point of a line 1,1,1, //x,y,z, of second point of a line ... Can you help me?

avatar image
1
Best Answer

Answer by Jean-Fabre · May 04, 2011 at 09:53 AM

HI,

If you can, I would start with this excel content reader

Else, like Christian Mentionned, you can play with String functions.

But you don't necessarly need to use IO, you can simply create a public variable like so:

public var myTextFile:TextAsset;

And link your text file into that public variable in the inspector.

Bye,

Jean

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Vector3 array from external .txt file 1 Answer

Problem with rotation around axis 1 Answer

Help with this script? Keeps moving my objects around in run-time? 0 Answers

How I can define the throw direction to a static GameObject? 1 Answer

Order matters when multiplying Quaternion by Vector3... Possible bug?? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges