Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 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
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1
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
Add comment · 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
0

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
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 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 $$anonymous$$d, you already solved it

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.

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 to use custom file types as Unity assets 1 Answer

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

Difference between Resources folder Vs normal folder 0 Answers

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

Standalone Build - Do not bundle resources (just create a folder) 0 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