• 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
Question by Snubber · Mar 16, 2021 at 01:23 PM · assetsserializationresourcesfiles

How can I load an custom file from the Assets folder?

I have raw files that I have built a custom serializer for. All I want to do is to be able to load the files from the game. (They need to be part of the game itself (not saved/loaded from the user's local files))

Comment
jerobarraco

People who like this

1 Show 0
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

2 Replies

  • Sort: 
avatar image
Best Answer

Answer by Snubber · Mar 16, 2021 at 03:35 PM

Okay I found a really hacky solution. If you put the file extension .txt at the end of the file name you can import the file as a text file. Then in your MonoBehavior create add a TextAsset property:

public TextAsset _textAsset;

Then you can access the file's bytes with:

_textAsset.bytes;

I hate this solution but it works.

Comment
jerobarraco

People who like this

1 Show 2 · 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 Snubber · Mar 16, 2021 at 03:40 PM 0
Share

Okay I have learned from https://docs.unity3d.com/Manual/class-TextAsset.html that you can also use the extension .bytes which makes me feel slightly better.

avatar image Snubber · Mar 16, 2021 at 03:40 PM 0
Share

Okay I have learned from https://docs.unity3d.com/Manual/class-TextAsset.html that you can also use the extension .bytes which makes me feel slightly better.

avatar image

Answer by undevable · Mar 16, 2021 at 02:24 PM

Two Methods to Load a File to the Assets Folder:

Method 1:

  1. Right Click on the Assets Section of Unity

  2. Select "Import File"

  3. Select your File

Method 2:

  1. Open File Explorer if you're on Windows, or Finder if you're on Mac

  2. Drag the file from File Explorer/Finder into the Assets Section of Unity

Hope this helps

Comment

People who like this

0 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 Snubber · Mar 16, 2021 at 03:08 PM 0
Share

I meant load a file with code from the Assets folder. I know how to drag and drop files :)

avatar image undevable Snubber · Mar 16, 2021 at 04:03 PM 0
Share

Oh, I'm sorry. Is the file a C# file? If it is I think you should be able to load it like normal

avatar image undevable undevable · Mar 16, 2021 at 04:04 PM 0
Share

Never mind, you already solved it

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

121 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 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 can I Instanciate a Prefab as it gets loaded from a LoadAssetsAsync,How can I Instanciate a Prefab as it gets loaded from a LoadAssetsAsync with Addressables? 1 Answer

How to load objects from a file outside of unity3d 3 Answers

Difference between Resources folder Vs normal folder 0 Answers

How to use custom file types as Unity assets 1 Answer

Why does my Unity project contain tens of thousands of files when the actual game assets is far less? 2 Answers


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