Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
2
Question by james 6 · Mar 28, 2011 at 08:49 AM · inputtextoutput

write to a text file in resrouce folder

i have a text file in my resource folder which i can read. i am just wondering how can i write to it and save it?

this is the code i use to access my text file in the folder:

 var tempAsset: TextAsset = Resources.Load("2011", TextAsset);
 var myString: String = tempAsset.text;

Comment
Add comment · Show 1
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 Fattie · Jan 25, 2016 at 10:07 PM 0
Share

It's impossible to write to a TextAsset (or indeed any other asset).

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Statement · Mar 28, 2011 at 12:17 PM

Only through editor scripts. See AssetDatabase.SaveAssets and EditorUtility.SetDirty. Note that you can not call these functions from game scripts. It has to be in the editor. Otherwise you can check out this question which might be similar to your needs. It works on standalone players.

import System.IO;

var myString : String = "Write some text!"; var file : String = "somefile.txt";

Load();

function Load() { myString = File.ReadAllText(file); }

function Save() { File.WriteAllText(file, myString); }

Comment
Add comment · 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
0

Answer by Justin Warner · Mar 28, 2011 at 11:54 AM

http://forum.unity3d.com/threads/5084-Can-I-read-and-write-text-files-using-Javascript

That should help you a little... I recomend searchign around a little first =). But good job finding out how to read!

Comment
Add comment · 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
0

Answer by drudiverse · Aug 24, 2015 at 05:32 AM

in JS... THIS WORKS!:)

 import System.IO;
  
 function writeStuffToFile(){
   var stuff : String = "stuff";
   File.WriteAllText(Application.dataPath +"/stuff.txt",stuff);
 }
  
 function readStufFromFile(){
   var stuff : String;
   stuff = File.ReadAllText(Application.dataPath +"/stuff.txt");
   Debug.Log(stuff);
 }

 
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 fafase · Aug 24, 2015 at 05:35 AM 0
Share

This is the same as the first answer from 2011.

avatar image Fattie fafase · Jan 25, 2016 at 10:02 PM 0
Share

@fafase - hi dude - they are BOTH WRONG, right?

You $$anonymous$$UST use

Application.persistentDataPath

particularly on Android, or you can't write.

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

2 People are following this question.

avatar image avatar image

Related Questions

Android Keyboard .text String returning empty? 1 Answer

mouse input - displays object description on screen 1 Answer

setting iPhoneKeyboard.text (or any workaround about resetting user input) in Android. 0 Answers

searching a text file for a player-input string 0 Answers

How to get print to transfer to a GUI Text? 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