// Update is called once per frame void Update() { if (AutoNext) { m_Button.GetComponent <Image>().sprite = selected; //0.02s left for this song if (MusicPlayer.GetSongLength() - MusicPlayer.GetAudioPosSec() < 0.02f) { int index = MusicWheelBase.GetCurSongIndex() + 1; if (index >= MusicWheelBase.GetWheelItemCount()) { index = 0; } MusicWheelItem item = GameObject.Find("WheelItem" + string.Format("{0}", index)).GetComponent <MusicWheelItem>(); MusicWheelBase.SetWheelPosIndex(index); item.ButtonClicked(); GameObject.Find("SongProgressBar").GetComponent <SongProgressbar>().SetProgress(0f); GameObject.Find("PlayButton").GetComponent <PlayButton>().ButtonOnClickEvent(); } } else { m_Button.GetComponent <Image>().sprite = normal; } }
// Update is called once per frame void Update() { gameObject.GetComponent <Text>().text = "CurrentSongs:" + MusicWheelBase.GetWheelItemCount() + " CurrentPacks:"; foreach (string s in MusicLoader.GetFolderFilter()) { gameObject.GetComponent <Text>().text = gameObject.GetComponent <Text>().text + s + " "; } }
public static void SetWheelPosIndex(int index) { float t = index * 1.0f / (MusicWheelBase.GetWheelItemCount() - 1); MusicWheelBase.UpdateWheelPos(t); Scrollbar m_Scrollbar = GameObject.Find("Scrollbar").GetComponent <Scrollbar>(); m_Scrollbar.value = t; }
public static int GetCurSongIndex() { int index = 0; for (int i = 0; i < MusicWheelBase.GetWheelItemCount(); i++) { if (MusicLoader.SongList[i].title == MusicPlayer.GetCurAudio()) { index = i; break; } } return(index); }
public void ButtonOnClickEvent() { int index = MusicWheelBase.GetCurSongIndex() + 1; if (index >= MusicWheelBase.GetWheelItemCount()) { index = 0; } MusicWheelItem item = GameObject.Find("WheelItem" + string.Format("{0}", index)).GetComponent <MusicWheelItem>(); MusicWheelBase.SetWheelPosIndex(index); item.ButtonClicked(); GameObject.Find("SongProgressBar").GetComponent <SongProgressbar>().SetProgress(0f); GameObject.Find("PlayButton").GetComponent <PlayButton>().ButtonOnClickEvent(); }
public void ButtonOnClickEvent() { if (MusicPlayer.GetIsPlaying()) { Debug.Log("Paused"); MusicPlayer.PauseAudio(); } List <int> itemlist = new List <int>(); for (int i = 0; i < MusicWheelBase.GetWheelItemCount(); i++) { MusicWheelItem item_t = GameObject.Find("WheelItem" + string.Format("{0}", i)).GetComponent <MusicWheelItem>(); if (!item_t.played) { itemlist.Add(i); } } if (itemlist.Count == 0) { return; } //Random.InitState(1); int index = Random.Range(0, itemlist.Count); GameObject.Find("RedoRandomButton").GetComponent <RedoRandom>().AddRandom(itemlist[index]); MusicWheelItem item = GameObject.Find("WheelItem" + string.Format("{0}", itemlist[index])).GetComponent <MusicWheelItem>(); float t = itemlist[index] * 1.0f / (MusicWheelBase.GetWheelItemCount() - 1); MusicWheelBase.UpdateWheelPos(t); Scrollbar m_Scrollbar = GameObject.Find("Scrollbar").GetComponent <Scrollbar>(); m_Scrollbar.value = t; item.ButtonClicked(); float pos = Random.Range(0f, 0.8f); if (GameObject.Find("LimTVSizeButton").GetComponent <LimitTVSize>().LimitTvSize) { float songlen = MusicPlayer.GetSongLength(); float sec = Random.Range(0f, 80f); sec = Mathf.Min(songlen - 15f, sec); pos = sec / songlen; } GameObject.Find("SongProgressBar").GetComponent <SongProgressbar>().SetProgress(pos); }
void Update() { if (blocked) { return; } if (m_Scrollbar.value < 0) { m_Scrollbar.value = 0; } if (m_Scrollbar.value > 1) { m_Scrollbar.value = 1; } if (HasFocus && Input.GetAxis("Mouse ScrollWheel") > 0 && m_Scrollbar.value > 0) { m_Scrollbar.value -= 0.02f * 150f / (MusicWheelBase.GetWheelItemCount() + 1); } if (HasFocus && Input.GetAxis("Mouse ScrollWheel") < 0 && m_Scrollbar.value < 1) { m_Scrollbar.value += 0.02f * 150f / (MusicWheelBase.GetWheelItemCount() + 1); } if (HasFocus && Input.touchCount == 1) { if (Input.touches[0].phase == TouchPhase.Began) { // 记录手指触屏的位置 m_screenpos = Input.touches[0].position; } // 手指移动 else if (Input.touches[0].phase == TouchPhase.Moved) { m_Scrollbar.value += Input.touches[0].deltaPosition.y / 50 * Time.deltaTime * 150f / (MusicWheelBase.GetWheelItemCount() + 1); } } }
public void ButtonOnClickEvent() { if (st.Count <= 1) { return; } //redo now int index = (int)st.Peek(); MusicWheelItem item_t = GameObject.Find("WheelItem" + string.Format("{0}", index)).GetComponent <MusicWheelItem>(); item_t.side_image_obj.SetActive(false); item_t.played = false; st.Pop(); index = (int)st.Peek(); MusicWheelItem item = GameObject.Find("WheelItem" + string.Format("{0}", index)).GetComponent <MusicWheelItem>(); float t = index * 1.0f / (MusicWheelBase.GetWheelItemCount() - 1); MusicWheelBase.UpdateWheelPos(t); Scrollbar m_Scrollbar = GameObject.Find("Scrollbar").GetComponent <Scrollbar>(); m_Scrollbar.value = t; item.ButtonClicked(); /* * float pos = Random.Range(0f, 0.8f); * if (GameObject.Find("LimTVSizeButton").GetComponent<LimitTVSize>().LimitTvSize) * { * float songlen = MusicPlayer.GetSongLength(); * float sec = Random.Range(0f, 80f); * pos = sec / songlen; * }*/ GameObject.Find("SongProgressBar").GetComponent <SongProgressbar>().SetProgress(0f); }
private static void CreateWheelItems(List <MusicData> mdata) { GameObject songlist = GameObject.FindGameObjectWithTag("SongList"); int index = 0; foreach (MusicData md in mdata) { GameObject musicwheelitem = new GameObject("WheelItem" + string.Format("{0}", index)); MusicWheelItem temp = musicwheelitem.AddComponent <MusicWheelItem>(); musicwheelitem.transform.parent = songlist.transform; temp.button_obj = new GameObject(); temp.button_obj.transform.parent = musicwheelitem.transform; temp.button_obj.transform.localPosition = new Vector3(19f, 0, 0f); temp.button = temp.button_obj.AddComponent <Button>(); //background image for item; temp.image = temp.button_obj.AddComponent <Image>(); temp.image.GetComponent <RectTransform>().sizeDelta = new Vector2(38f, 6f); temp.image.color = new Color(255 / 255f, 255 / 255f, 255 / 255f, 125 / 255f); //temp.button.GetComponent<RectTransform>().sizeDelta = new Vector2(40f, 6f); temp.button.targetGraphic = temp.image; temp.button.onClick.RemoveAllListeners(); temp.button.onClick.AddListener(temp.ButtonClicked); ColorBlock cb = new ColorBlock(); cb = temp.button.colors; cb.normalColor = new Color(255 / 255f, 255 / 255f, 255 / 255f, 120 / 255f); cb.highlightedColor = new Color(0 / 255f, 255 / 255f, 255 / 255f, 20 / 255f); cb.pressedColor = new Color(0 / 255f, 255 / 255f, 255 / 255f, 20 / 255f); cb.selectedColor = new Color(0 / 255f, 255 / 255f, 255 / 255f, 10 / 255f); cb.fadeDuration = 0.5f; temp.button.colors = cb; temp.text_title = new GameObject(); temp.text_title.transform.parent = musicwheelitem.transform; temp.text_title_tm = temp.text_title.AddComponent <TextMesh>(); temp.text_artist = new GameObject(); temp.text_artist.transform.parent = musicwheelitem.transform; temp.text_artist_tm = temp.text_artist.AddComponent <TextMesh>(); temp.text_animation = new GameObject(); temp.text_animation.transform.parent = musicwheelitem.transform; temp.text_animation_tm = temp.text_animation.AddComponent <TextMesh>(); temp.text_translated = new GameObject(); temp.text_translated.transform.parent = musicwheelitem.transform; temp.text_translated_tm = temp.text_translated.AddComponent <TextMesh>(); temp.transform.localScale = new Vector3(8f, 8f, 8f); temp.transform.localPosition = new Vector3(-160, -20 + index * 50, -1); temp.text_title_tm.text = LanguageManager.UTF8String(md.title); temp.text_artist_tm.text = LanguageManager.UTF8String(md.artist); temp.text_animation_tm.text = LanguageManager.UTF8String(md.animation); temp.text_translated_tm.text = LanguageManager.UTF8String(md.translated); temp.text_title.transform.localPosition = new Vector3(0, 2.8f, 0); temp.text_title_tm.fontSize = 24; temp.text_artist.transform.localPosition = new Vector3(0, -1f, 0); temp.text_artist_tm.fontSize = 12; temp.text_animation.transform.localPosition = new Vector3(38, -0.8f, 0); temp.text_animation_tm.fontSize = 16; temp.text_animation_tm.anchor = TextAnchor.UpperRight; temp.text_translated.transform.localPosition = new Vector3(38f, 2.6f, 0f); temp.text_translated_tm.fontSize = 16; temp.text_translated_tm.anchor = TextAnchor.UpperRight; musicwheelitem.layer = LayerMask.NameToLayer("UI"); foreach (Transform tran in musicwheelitem.GetComponentsInChildren <Transform>()) { //遍历当前物体及其所有子物体 tran.gameObject.layer = LayerMask.NameToLayer("UI"); //更改物体的Layer层 } //temp.button_obj.transform.gameObject.layer = LayerMask.NameToLayer("Background"); temp.index = index; index++; } MusicWheelBase.UpdateWheelItemCount(index); }
public void ButtonOnClickEvent() { int index = MusicWheelBase.GetCurSongIndex(); MusicWheelBase.SetWheelPosIndex(index); }
// Update is called once per frame void Update() { gameObject.transform.localPosition = new Vector3(-160, -index * 50 + MusicWheelBase.GetWheelPos() * (MusicWheelBase.GetWheelItemCount() - 1) * 50, -1); }
// Update is called once per frame void Update() { if (FullAuto) { m_Button.GetComponent <Image>().sprite = selected; if (MusicPlayer.GetIsPlaying()) { timer += Time.deltaTime; if (timer > max_time || MusicPlayer.GetSongLength() - MusicPlayer.GetAudioPosSec() < 0.02f) { List <int> itemlist = new List <int>(); for (int i = 0; i < MusicWheelBase.GetWheelItemCount(); i++) { MusicWheelItem item_t = GameObject.Find("WheelItem" + string.Format("{0}", i)).GetComponent <MusicWheelItem>(); if (!item_t.played) { itemlist.Add(i); } } if (itemlist.Count == 0) { //放完了 timer = 0f; fading = false; MusicPlayer.SetVolume(GameObject.Find("SongVolumeBar").GetComponent <Scrollbar>().value); FullAuto = !FullAuto; GameObject.Find("PlayButton").GetComponent <PlayButton>().ButtonOnClickEvent(); } else { timer = 0f; fading = false; GameObject.Find("RandomNextButton").GetComponent <RandomNext>().ButtonOnClickEvent(); //MusicPlayer.SetVolume(volume); MusicPlayer.SetVolume(GameObject.Find("SongVolumeBar").GetComponent <Scrollbar>().value); //GameObject.Find("SongVolumeBar").GetComponent<Scrollbar>().value = volume; GameObject.Find("PlayButton").GetComponent <PlayButton>().ButtonOnClickEvent(); } } if (!fading) { //volume = MusicPlayer.GetVolume(); } if (timer > max_time - fade_time) { fading = true; //MusicPlayer.SetVolume(volume * (max_time - timer) / (max_time-fade_time)); MusicPlayer.SetVolume(GameObject.Find("SongVolumeBar").GetComponent <Scrollbar>().value *(max_time - timer) / (max_time - fade_time)); // GameObject.Find("SongVolumeBar").GetComponent<Scrollbar>().value = volume * (max_time - timer) / (max_time - fade_time); } /* * else * { * volume = MusicPlayer.GetVolume(); * }*/ } else { timer = 0f; } } else { m_Button.GetComponent <Image>().sprite = normal; } }
private void OnValueChangedPrivate(float T) { MusicWheelBase.UpdateWheelPos(T); //print("代码控制" + T); }