Programming/Unity3D
File 읽어오기
Nine99
2010. 10. 8. 16:22
string url = "http://nine99.tistory.com/xxx.xml";
이런식의 웹데이터도 읽어올 수 있다.
또한, ogg 같은 Sound Clip 도 읽어 올 수 있음.( mp3 나 wav 는 읽어올 수 없음, unity3D 에서 지원하지 않음)
using UnityEngine;
using System.Collections;
using System.Xml;
using System;
public class XXX : monoBehaviour {
string xmlString;
public IEnumerator WaitForXML()
{
yield return www;
xmlString = www.text;
print( xmlString );
}
public void TestFunction()
{
string url = "file://NoteData.xml";
www = new WWW( url );
StartCoroutine( WaitForXML() );
if ( www.error == null )
{
}
else
{
Debug.Log( "ERROR : " + www.error );
}
}
void OnGUI()
GUILayout.BeginArea( new Rect( 5, 25, 100, 400 ) );
//............................
if ( GUILayout.Button( "Test Button" ) )
{
TestFunction();
}
GUILayout.EndArea();
}
}
|