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
5
Question by Noam · Oct 17, 2010 at 12:54 PM · editorbuildbuildpipeline

Copy a resource file to build directory?

Hi,

Part of my game includes a native plugin I use, that needs direct access to my model's FBX file (and another file). Both of the files are part of my unity project, and I reference them in my scripts (their locations are saved as strings in my objects etc).

This becomes problematic when building the game for a standalone build. I don't know how I can flag files to be copied to the output directory. While I can manage this myself when its two files, that number will grow by a lot until the final version of our game.

Is there any way to automate this process? (Ideally, I would like to be able to flag certain assets as 'binary runtime assets' or something similar, and have them exported to the build directory. Is there any way to do this? Workarounds are also very welcome.

Thanks!

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
2
Best Answer

Answer by Clem · Mar 31, 2011 at 01:40 PM

You could write a custom build script that copies the file(s) for you. Something like:

string[] scenes = {"Assets/myScene.unity"};

BuildPipeline.BuildPlayer(scenes , "Build/game.unity3d", BuildTarget.WebPlayer, BuildOptions.BuildAdditionalStreamedScenes);

File.Copy(sourceFile, Path.Combine("Build", sourceFileName));

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 Noam · Apr 03, 2011 at 11:21 AM 0
Share

That would work, but would not be modular, as I have to put everything in one script. I could write an entire system for a custom build script, perhaps.

avatar image andresp · Sep 13, 2011 at 03:24 PM 0
Share

the only problem is that BuildPlayer is a function only available in Unity Pro

avatar image
3

Answer by castor · Jan 17, 2017 at 07:36 PM

Why not use the StreamingAssets folder? That's for those cases I think.

https://docs.unity3d.com/Manual/StreamingAssets.html https://docs.unity3d.com/ScriptReference/Application-streamingAssetsPath.html

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 Bunny83 · Jan 17, 2017 at 09:00 PM 1
Share

Because the question was from 2010 and there was no Strea$$anonymous$$gAssets folder back then. It's a "more recent addition". Specifically the support for the Strea$$anonymous$$gAssets for windows and mac builds was added in version 3.5. Before that feature was an iOS only feature. Also Application.strea$$anonymous$$gAssetsPath was also added in this version.

You got my upvote since of course Strea$$anonymous$$gAssets is now the way to go. However keep the posting time in $$anonymous$$d next time ^^. Unity as well as UnityAnswers exist for a long time now and Unity has evolved quite a bit. A lot things that weren't possible in the beginning / a year ago are now implemented.

avatar image castor Bunny83 · Jan 17, 2017 at 09:07 PM 1
Share

Good point! The reason I replied is because I was looking for an answer to the exact problem and didn't realize how out of the date the thread was. I honestly feel the answer is still valid, in the sense that another developer just like me will very likely stumble into this answer without realizing how old it is. Also, is there a way to flag an answer as outdated?

avatar image Bilelmnasser · Oct 04, 2017 at 07:12 AM 1
Share

this is the best answer for this question guys !

avatar image
2

Answer by Jason 15 · Feb 19, 2011 at 04:40 AM

The only way I've found so far is to put your file(s) in the root of the Plugins directory and append the '.dll' extension to them, even if they're not dlls. For example, if you have text.xml then name it text.xml.dll. I had to load an XML file in an external .dll plugin (so I couldn't use the Unity Resources or TextAsset class). This is the solution I used and it works fine, if a little hack-y.

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 Noam · Feb 27, 2011 at 03:27 PM 0
Share

Yea, we ended up doing something similar as well...

avatar image Dan Wagner · Aug 03, 2011 at 09:23 AM 0
Share

I've tried this on a $$anonymous$$ac build, but after building I could not find it within the $$anonymous$$ac package.

avatar image andresp · Sep 13, 2011 at 03:28 PM 0
Share

how could you access the files after the build? because unity places the Plugins folder within a different folder (which name is based on the exe name on Windows - EXE_NA$$anonymous$$E + "_Data").

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Developer Console doesn't show up when using BuildOptions.Developer 0 Answers

Cancel build in PostProcessScene? 0 Answers

Automate exclusion of specific Android plugin from build? 0 Answers

Distribute terrain in zones 3 Answers

Create custom warning dialog on build, if a script or gameobject exists in the scene 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