خواندن و نوشتن فایل در یونیتی

using UnityEngine;
using UnityEditor;
using System.IO;

public class HandleTextFile
{
   [MenuItem("Tools/Write file")]
   static void WriteString()
   {
       string path = "Assets/Resources/test.txt";

       //Write some text to the test.txt file
       StreamWriter writer = new StreamWriter(path, true);
       writer.WriteLine("Test");
       writer.Close();

       //Re-import the file to update the reference in the editor
       AssetDatabase.ImportAsset(path);
       TextAsset asset = Resources.Load("test");

       //Print the text from the file
       Debug.Log(asset.text);
   }

   [MenuItem("Tools/Read file")]
   static void ReadString()
   {
       string path = "Assets/Resources/test.txt";

       //Read the text from directly from the test.txt file
       StreamReader reader = new StreamReader(path);
       Debug.Log(reader.ReadToEnd());
       reader.Close();
   }

}



مثال دیگر:


public string FileName; // This contains the name of the file. Don't add the ".txt"
                         // Assign in inspector
 private TextAsset asset; // Gets assigned through code. Reads the file.
 private StreamWriter writer; // This is the writer that writes to the file
 void AppendString(string appendString) {
   asset = Resources.Load(FileName + ".txt") as TextAsset;
   writer = new StreamWriter("Resources/" + FileName + ".txt"); // Does this work?
   writer.WriteLine(appendString);
 }


http://s8.picofile.com/file/8324942000/textFile.jpg

حل مشکل عوض شدن صدای مرد به زن در مدیا پلیر ویندوز xp و 7و 8 و غیره

رفع مشکل اتصال اندروید به اینترنت مودم _ رفع مشکل عدم اتصال گوشی به اینترنت

آیه ی قرآن برای افزایش رزق و روزی _ 26 و 27 آل عمران هر روز با توجه بخوانید

the ,       ,   ,writer ,txt ,test ,test txt ,در یونیتی ,the file ,txt file       ,filename txt ,path assets resources

مشخصات

تبلیغات

آخرین مطالب این وبلاگ

آخرین ارسال ها

برترین جستجو ها

آخرین جستجو ها

لوازم خانگی 12 موزیک هنرستان فنی وحرفه ای دخترانه سمیه آخرین اخبار مهاجرت به کانادا | ترکیه | آمریکا متن سرودهای اسلامی انجمن تاریخ شهرستانهای تهران ترومن سوپر اس یو خرید سرور اچ پی پِریسکه‌ی جان