import System.IO;
import System.Windows.Forms;
var filecount =0;
var Audiopathname = new Array();
var Audiofilename = new Array();
var AudioButton = new Array();
var myFile : FileInfo;
var AudioStyle : GUIStyle;
var PicStyle : GUIStyle;
var obj : GameObject;
function Start () {
}
function Update () {
if(Input.GetKey(KeyCode.Escape))
UnityEngine.Application.Quit();
for(var i : int = 0;i<filecount;i++)
{
if(AudioButton[i])
ChangeAudio(Audiopathname[i]);
}
}
function OnGUI(){
if(GUI.Button(Rect(UnityEngine.Screen.width*0.7, UnityEngine.Screen.height*0.9, UnityEngine.Screen.width*0.17, UnityEngine.Screen.height*0.06),"",AudioStyle)){
var Myofd : OpenFileDialog= new OpenFileDialog();
Myofd.InitialDirectory ="file://"+UnityEngine.Application.dataPath;
Myofd.Multiselect=true;
Myofd.Filter="音频文件(*.ogg,*.wav)|*.ogg;*.wav";
Myofd.FilterIndex=2;
if(Myofd.ShowDialog()==DialogResult.OK){
filecount = Myofd.FileNames.Length;
Audiopathname.length = filecount;
AudioButton.length = filecount;
Audiofilename.length = filecount;
for(var i : int = 0;i<filecount;i++)
{
Audiopathname[i] = Myofd.FileNames[i];
myFile=FileInfo(Myofd.FileNames[i]);
Audiofilename[i]=myFile.Name;
}
}
}
if(GUI.Button(Rect(UnityEngine.Screen.width*0.7, UnityEngine.Screen.height*0.8, UnityEngine.Screen.width*0.17, UnityEngine.Screen.height*0.06),"",PicStyle)){
var Mypicofd : OpenFileDialog= new OpenFileDialog();
Mypicofd.InitialDirectory ="file://"+UnityEngine.Application.dataPath;
if(Mypicofd.ShowDialog()==DialogResult.OK){
Debug.Log(Mypicofd.FileName);
changetexture(Mypicofd.FileName);
}
}
if(filecount>0){
for(var j : int = 0;j<filecount;j++)
{
AudioButton[j] = GUI.Button(Rect(UnityEngine.Screen.width*0.1,UnityEngine.Screen.height*0.1+UnityEngine.Screen.height*0.1*j,UnityEngine.Screen.width*0.2,UnityEngine.Screen.height*0.1),Audiofilename[j]);
}
}
}
function ChangeAudio(name: String) {
www = new WWW("file://" + name);
yield www;
UnityEngine.Resources.UnloadUnusedAssets();
GetComponent.<AudioSource>().clip = www.GetAudioClip();
GetComponent.<AudioSource>().Play();
}
function changetexture(name : String){
www = new WWW ("file://"+name);
yield www;
UnityEngine.Resources.UnloadUnusedAssets();
obj.GetComponent.<Renderer>().material.mainTexture=www.texture;
}
import System.Windows.Forms;
var filecount =0;
var Audiopathname = new Array();
var Audiofilename = new Array();
var AudioButton = new Array();
var myFile : FileInfo;
var AudioStyle : GUIStyle;
var PicStyle : GUIStyle;
var obj : GameObject;
function Start () {
}
function Update () {
if(Input.GetKey(KeyCode.Escape))
UnityEngine.Application.Quit();
for(var i : int = 0;i<filecount;i++)
{
if(AudioButton[i])
ChangeAudio(Audiopathname[i]);
}
}
function OnGUI(){
if(GUI.Button(Rect(UnityEngine.Screen.width*0.7, UnityEngine.Screen.height*0.9, UnityEngine.Screen.width*0.17, UnityEngine.Screen.height*0.06),"",AudioStyle)){
var Myofd : OpenFileDialog= new OpenFileDialog();
Myofd.InitialDirectory ="file://"+UnityEngine.Application.dataPath;
Myofd.Multiselect=true;
Myofd.Filter="音频文件(*.ogg,*.wav)|*.ogg;*.wav";
Myofd.FilterIndex=2;
if(Myofd.ShowDialog()==DialogResult.OK){
filecount = Myofd.FileNames.Length;
Audiopathname.length = filecount;
AudioButton.length = filecount;
Audiofilename.length = filecount;
for(var i : int = 0;i<filecount;i++)
{
Audiopathname[i] = Myofd.FileNames[i];
myFile=FileInfo(Myofd.FileNames[i]);
Audiofilename[i]=myFile.Name;
}
}
}
if(GUI.Button(Rect(UnityEngine.Screen.width*0.7, UnityEngine.Screen.height*0.8, UnityEngine.Screen.width*0.17, UnityEngine.Screen.height*0.06),"",PicStyle)){
var Mypicofd : OpenFileDialog= new OpenFileDialog();
Mypicofd.InitialDirectory ="file://"+UnityEngine.Application.dataPath;
if(Mypicofd.ShowDialog()==DialogResult.OK){
Debug.Log(Mypicofd.FileName);
changetexture(Mypicofd.FileName);
}
}
if(filecount>0){
for(var j : int = 0;j<filecount;j++)
{
AudioButton[j] = GUI.Button(Rect(UnityEngine.Screen.width*0.1,UnityEngine.Screen.height*0.1+UnityEngine.Screen.height*0.1*j,UnityEngine.Screen.width*0.2,UnityEngine.Screen.height*0.1),Audiofilename[j]);
}
}
}
function ChangeAudio(name: String) {
www = new WWW("file://" + name);
yield www;
UnityEngine.Resources.UnloadUnusedAssets();
GetComponent.<AudioSource>().clip = www.GetAudioClip();
GetComponent.<AudioSource>().Play();
}
function changetexture(name : String){
www = new WWW ("file://"+name);
yield www;
UnityEngine.Resources.UnloadUnusedAssets();
obj.GetComponent.<Renderer>().material.mainTexture=www.texture;
}