• 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
0
Question by Lauris48 · Jun 07, 2019 at 07:34 AM · textassetreading datastreamreader

TextAsset read non txt files

Hi, I have unrecognised extension of the file (any but not .txt), but i want to use that in StreamReader. I also want to add that file trough Unity's inspector, via public variable. Is there any way to do it? Is there any other variable type that I could use, instead of TextAsset ?

Thank you.

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Lauris48 · Jun 07, 2019 at 07:47 AM

Found answer here: https://answers.unity.com/questions/1351604/is-it-possible-to-reference-a-custom-file-type-in.html

I guess my best solution is to rename these files to .txt

Comment
Add comment · Show 1 · 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 Bunny83 · Jun 07, 2019 at 09:00 AM 0
Share

If something isn't text it's best to add the extention .bytes

avatar image
0

Answer by Pangamini · Jun 07, 2019 at 08:41 AM

You can read files normally using System.IO.FIle class. You are not limited to any Unity tools for working with files. The TextAsset is what it says - an asset. It uses unity references, derives from UnityEngine.Object. It has nothing to do with file access, and it won't be present as a file in the build. The usual location for files that you want preserved in their original binary form in the build is the StreamingAssets folder. You can get the folder path by using Application.streamingAssetsPath and store any files that should be part of the build here. But you can also load any files from any location where the OS gives your app an access permission.

I use StreamingAssets for storing my custom config files and savegame files, and generally anything that can be changed during the game and written back to be preserved between app runs

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
avatar image
0

Answer by alakoring · Apr 29, 2020 at 10:15 PM

According to https://docs.unity3d.com/Manual/StreamingAssets.html, “On many platforms, the streaming assets folder location is read-only.” Sounds like a bad place for save files!

As for configuration files, my current thought is to avoid this because players can find and change them. Text assets aren’t exposed in the same way.

Which is why it would be super useful if there were a way to use arbitrary extensions as text assets (.lua in my case)…

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

109 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to streamread and parse. 0 Answers

What is better for text reading and writing? 1 Answer

Using OpenFilePanel at runtime to open a file as a TextAsset to read data is giving NullReferenceException 0 Answers

How to use UnityWebRequest to access local text file on Andorid build 0 Answers

Change contents of TextAsset 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges