Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
This question was closed Jan 11, 2020 at 03:17 AM by valentin56610 for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by valentin56610 · Jan 10, 2020 at 07:59 PM · build-errorfilebinaryio

can't seem to open binary file after game is built (inside asset folder)

Hi

My game has a campaign system in which every map is a separate file I made in my custom map editor. So I save the map (which is a binary custom file) and so everything works great in the editor, I can open the file and load the map, but once I build the game and try the campaign in the built version of the game, it can't seem to locate the file and thus, open it. The file is located in the Asset folder of my Unity project. I have tried to move it to the resources folder but same problem.

Is there something I ignore about unity destroying custom files once the game is built ? Then destroying my campaign files ? I don't really understand the problem as it seems to find everything when I am in the editor. Hope my question is clear enough !

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

  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Jan 11, 2020 at 01:31 AM

No, Unity does not "destroy" files. It's actually the other way round. No source files will be included in a build. Your Assets folder is a project staging folder. Unity only includes used / referenced assets in a build. However not in the source format. Assets are packed / converted into Unity's asset format.


What you probably are looking for is the StreamingAssets folder. Please read the documentation carefully. If you build for Android or WebGL the streaming assets can not be accessed through the normal file system. In this case you have to use a UnityWebRequest or the WWW class.

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 valentin56610 · Jan 11, 2020 at 02:57 AM 1
Share

Ok so this is what I came up with :

 //file = File.Open("Assets/Campaign/" + $$anonymous$$ain$$anonymous$$enu.mapName, File$$anonymous$$ode.Open);
 file = File.Open(Application.strea$$anonymous$$gAssetsPath + "Campaign/" + $$anonymous$$ain$$anonymous$$enu.mapName, File$$anonymous$$ode.Open);
 gameData = (GameData)bf.Deserialize(file);

But it is not working :( I am not sure if this is even what I need ? I don't really know what I'm looking for or how to have custom files into a build that I can access from within the game. Also, I am developing it for windows/$$anonymous$$ac, no mobile version is planned Do I have to create a Strea$$anonymous$$gAsset folder and place my files in there in order to access them ?

avatar image Bunny83 valentin56610 · Jan 11, 2020 at 03:16 AM 2
Share

So you haven't read the documentation carefully ^^:

From the documentation:

Unity copies any files placed in the folder called Strea$$anonymous$$gAssets (case-sensitive) in a Unity Project verbatim to a particular folder on the target machine

This is a special folder like an "Editor" or "Resources" folder. The folder has to be located directly inside your Assets folder (like the plugins folder). $$anonymous$$aybe also have a look at the special folder names page

avatar image valentin56610 Bunny83 · Jan 11, 2020 at 03:18 AM 1
Share

Yeah I got it working after a couple of tries and re reading the documentation. Thank you very much ! Saved my life for this one haha

avatar image
1

Answer by valentin56610 · Jan 11, 2020 at 03:15 AM

To whomever who has the same problem as me, here is the solution. Go to your Asset folder in your unity project, there create a "StreamingAssets" folder, and this folder will be accessible once your game is built. the code to use is the following :

 file = File.Open(Application.streamingAssetsPath + "/Campaign/" + MainMenu.mapName, FileMode.Open);


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 markoin · Oct 19, 2020 at 07:50 PM 0
Share

I DID ALL OF THIS AND ITS STILL NOT WORKING AAAAAARGH

Follow this Question

Answers Answers and Comments

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

Not writing to file correctly 1 Answer

Unity rewrite sln file causing Assembly-CSharp error 1 Answer

Access to the path is denied 0 Answers

[SOLVED]File don't save in persistentDataPath 1 Answer

Unity Errors when building 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