txt 파일 생성 및 저장(I/O)
게임을 만들다 보면 파일 입출력( input / output )을 사용해야 할 경우가 종종 있다.
지금은 에디터 작업을 하다가 사용하게 되어서 이렇게 정리하게 되었다.
using System.IO;
string fullPth ="Assets/경로"
if(false == File.Exists( fullPath )){
var file = File.CreateText( fullPath + ".txt");
file.Close();
}
반응형
System을 사용하기 위해서 import 하고
해당 파일이 있는지 확인하고 없는경우에 파일을 생성하도록 했다.
StreamWriter sw = new StreamWriter( fullPath );
sw.WriteLine("저장된 데이터");
sw.Flush();
sw.Close();
파일을 읽기위해서는 StreamWriter를 사용해서 해당 데이터를 저장하고 메모리를 날리고 close 처리해준다.
URL :https://docs.unity3d.com/ScriptReference/Windows.File.html
Unity - Scripting API: File
Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close
docs.unity3d.com
★★☆☆☆
반응형
'개발 > Unity' 카테고리의 다른 글
Unity) 스크롤 뷰 커스텀 ScrollView Custom (가로, 세로 동시) (13) | 2020.07.01 |
---|---|
정리)Dev Weeks: 작업 효율을 높이기 위한 유니티 UI 제작 프로그래밍 패턴들 (2) | 2020.06.29 |
소식)Unity 2019 LTS (1) | 2020.06.14 |
Unity) 오브젝트 바라보게하기(Lookat) (0) | 2020.06.11 |
Unity) 워크플로우 속도 향상을 위한 기능 5가지(2019 v) (0) | 2020.06.01 |
댓글