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 /
avatar image
0
Question by AgeTDev · Mar 12, 2016 at 11:41 AM · editorassetsaveexportsettings

Export Settings or custom files to release builds

Hello everyone! I got a little question I am building an asset at the moment and I am struggling with something.

I created a settings page where users can enter details and stuff, but how do I get these to the release build? I can save them in files at editor runtime but then when building, these files are ofc not taken with into the build. So what is the best method of doing so ?

I tought of creating automated code based on the settings that gets executed on the first run but that is suboptimal at best.

Any suggestions?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by toddisarockstar · Mar 12, 2016 at 06:41 PM

if you are building for standalone you should make sure you are using the resourse folder for your file path

 import System.IO;
 //write
 if(!File.Exists(Application.dataPath+"/Resources/settings.txt")){  
 var swmap : StreamWriter = new StreamWriter
 (Application.dataPath+"/Resources/settings.txt");
  swmap.WriteLine("here are my settings");
 swmap.Flush();swmap.Close();} 
 
 //read
 var loadsettings:TextAsset;                                                                                                              
      loadsettings=Resources.Load("settings")as TextAsset;

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 AgeTDev · Mar 12, 2016 at 07:16 PM 0
Share

Hello! Thank you for your reply. I figured this was the way to go but I got confused whether Resources I available after a project has been built or not.

A little question, the scripting reference says

The path is relative to any Resources folder

It says Any resources folder. Does this mean I I have a Resources folder as a subfolder somewhere ?

Thank you, T

avatar image toddisarockstar AgeTDev · Mar 14, 2016 at 06:40 PM 0
Share

yes, anything in your assetts folder should carry out to the build. if you use the resourses folder (which is a folder inside your assetts folder). You get some advantages with using the Resourses.load function.

I believe the resources folder should already be there by default but if not you could simple say something like this:

 if(!System.IO.Directory.Exists("file path here")){
 System.IO.Directory.CreateDirectory("file path here");}

or just put it there manually in unity before the build. depending on what your doing, the File path is not always relative to resourses folders, because of course you can write to any drive wherever you want outside the game folder.

when playing with files usually if you want to write reletive to your game folder you say Application.datapath first.

when you call resource.load i think there is an exeption. i don't think it needs the whole path.

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

44 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

Related Questions

Editor Window with settings and Asset Creation 1 Answer

Auto-export to asset only files and such used in scene 1 Answer

Custom editor DLLs 1 Answer

Generated sprite asset cannot be tinkered like an image in editor 0 Answers

How to share project settings on asset server? 1 Answer


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