usingUnityEngine;
usingSystem.Collections;
usingUnityEngine.UI;
publicclassMusicController:MonoBehaviour{
private AudioSource Backaudio;
//private float value=1;
private string[ ] picName;
public Image picImage;
private int index=0;
//public Button button;
voidStart( ){
Backaudio=GetComponent();
picName=newstring[]{"image1","image2","image3","image4","image5","image6"};
//使选中按钮显示高亮状态
//button=GetComponent( ).Select( );
}
publicvoidToggleChange(boolisChiose){
if(isChiose){
print("播放音乐");
Backaudio.Play();
}else{
print("关闭音乐");
Backaudio.Stop();
}
}
//publicvoidTogglechange(boolisChiose){
//
//if(isChiose){
//print("关闭音乐");
//Backaudio.Stop();
//
//}
//}
public void VolumeChange(float value){
Backaudio.volume=value;
}
//voidOnGUI(){
////生成一个滑条并控制滑条的滑动
//value=GUI.HorizontalSlider(newRect((Screen.width-100)/2,Screen.height/2,200,30),value,leftValue:1.0f,rightValue:0.0f);
//Backaudio.volume=value;
//}
publicvoidButtonPressed( ){
index++;
index=index%picName.Length;
//1从资源文件夹Resources中加载图片
Sprite pic=Resources.Load(picName[index],typeof(Sprite))asSprite;
picImage.sprite=pic;
//2从资源文件夹Resources中加载图片
//Spritepic2=Resources.Load(picName[index]);
//picImage.sprite=pic2;
}
}