using UnityEngine;
using System.Collections;
using System;
using System.IO;
public class CsTextManager : MonoBehaviour {
public GUISkin skin;
private int currentTextNumber;//현재 텍스트 번호
string s;
// Use this for initialization
void Start () {
currentTextNumber = 0;
s = LoadTextFile("text/opening.txt");
print(s);
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0))
{
currentTextNumber++;
}
}
string LoadTextFile(string fileName)
{
string t = "";
string line = "";
StreamReader sr = new StreamReader(Application.dataPath + "/Resources/" + fileName);
if (sr == null)
{
print("Error : " + Application.dataPath + "/Resources/" + fileName);
}
else
{
line = sr.ReadLine();
while (line != null)
{
t += line;
line = sr.ReadLine();
if (line != null)
{
t += "\n";
}
}
sr.Close();
// print("Loaded " + Application.dataPath + "/Resources/db/" + fileName);
}
return t;
}
//gui
void OnGUI()
{
//텍스트 파일에서 읽기
GUI.skin = skin;
int halfW = Screen.width / 2;
int halfH = Screen.height / 2;
int x = 40;
int y = halfH + 40;
GUI.Label(new Rect(x, y, halfW * 1, halfH * 1.2f), s);
}
}
'잡다한것들전부 > 팁' 카테고리의 다른 글
| PlayerPrefs 배열로 저장하기 (0) | 2013.12.14 |
|---|---|
| 유니티 텍스트 파일 읽기 (0) | 2013.12.14 |
| 유니티 텍스트 파일 읽기 (0) | 2013.12.14 |
| ngui 강좌 링크 (0) | 2013.12.12 |
| 유니티 rpg 강좌 (0) | 2013.12.11 |
| 메모리 문제 (0) | 2013.12.11 |


