void Update() { ShowCurAudioState(); Ray2D ray = new Ray2D(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero); RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction); #region 왼쪽 마우스 클릭 if (Input.GetMouseButtonDown(0) && hit.collider != null) { if (hit.collider.gameObject.name == "Gauge" && audioSource.clip != null) { stateBar.ChangeStatusBar(ref ray); } if (hit.collider.gameObject.CompareTag("StatusBar") && audioSource.clip != null) { stateBar.b_Drag = true; } if ((hit.collider.gameObject.CompareTag("Line") || hit.collider.gameObject.CompareTag("LineLine")) && audioSource.clip != null) { CreateNote(ref ray, ref hit); } else if (hit.collider.gameObject.name == "Note") { if (NoteButton.b_touchNoteButton) { hit.collider.gameObject.GetComponent <Note>().SetNoteType(); } else if (ScoreButton.b_touchScoreButton) { hit.collider.gameObject.GetComponent <Note>().SetScoreType(); } else if (EffectSoundManager.b_TouchESD) { hit.collider.gameObject.GetComponent <Note>().SetEffect(EffectSoundManager.audioClip); } else { hit.collider.gameObject.GetComponent <Note>().PlaySound(); } } if (hit.collider.gameObject.CompareTag("Scrollbar")) { scrollbar.b_Drag = true; } if (hit.collider.gameObject.CompareTag("EffectSound") && hit.collider.gameObject.GetComponent <EffectSound>().audioClip != null) { EffectSoundManager.b_TouchESD = true; NoteButton.b_touchNoteButton = false; ScoreButton.b_touchScoreButton = false; EffectSoundManager.audioClip = hit.collider.gameObject.GetComponent <EffectSound>().audioClip; AudioSource.PlayClipAtPoint(EffectSoundManager.audioClip, Camera.main.transform.position); } if (hit.collider.gameObject.CompareTag("LineScrollBar") && audioSource.clip != null) { lineScrollbar.b_Drag = true; } } #endregion #region 오른쪽 마우스 클릭 else if (Input.GetMouseButtonDown(1) && hit.collider != null) { if (hit.collider.gameObject.name == "Note") { Note clone = hit.collider.gameObject.GetComponent <Note>(); clone.DeleteNote(); noteMgr.notes.Remove(clone); } if (hit.collider.gameObject.name == "Gauge" && audioSource.clip != null) { if (!b_readyRepeat && !b_startRepeat) { repeatRange = GameObject.Instantiate(repeatRangePrf); repeatRange.name = "RepeatRange"; repeatRange.transform.position = new Vector2(ray.origin.x, hit.collider.gameObject.transform.position.y); startPos = ray.origin; repeatRange.transform.localScale = new Vector3(0.05f, 0.5f, 1); b_readyRepeat = true; } else if (!b_startRepeat && b_readyRepeat) { if (startPos.x <= ray.origin.x) { repeatRange.transform.localScale = new Vector3((ray.origin.x - startPos.x), 0.5f, 1); repeatRange.transform.position = new Vector2(repeatRange.transform.position.x /*+ (ray.origin.x - repeatRange.transform.position.x) * 0.1f*/, repeatRange.transform.position.y); endPos = new Vector2(ray.origin.x, repeatRange.transform.position.y); } else { Vector2 tempPos = new Vector2(ray.origin.x, repeatRange.transform.position.y); endPos = startPos; startPos = tempPos; repeatRange.transform.localScale = new Vector3(endPos.x - startPos.x, 0.5f, 1); repeatRange.transform.position = new Vector2(repeatRange.transform.position.x - (repeatRange.transform.position.x - ray.origin.x), repeatRange.transform.position.y); } b_startRepeat = true; } } if (hit.collider.gameObject.CompareTag("EffectSound") && hit.collider.gameObject.GetComponent <EffectSound>().audioClip != null) { hit.collider.gameObject.GetComponent <EffectSound>().audioClip = null; hit.collider.gameObject.GetComponent <EffectSound>().text_name.text = "NULL"; } } #endregion #region UI_ScrollBar 드래그 if (scrollbar.b_Drag && !Input.GetMouseButtonUp(0)) { scrollbar.DragBar(ref ray); } else if (scrollbar.b_Drag && Input.GetMouseButtonUp(0)) { scrollbar.b_Drag = false; } #endregion #region UI_StatusBar 드래그 if (stateBar.b_Drag && !Input.GetMouseButtonUp(0)) { stateBar.ChangeStatusBar(ref ray); } else if (stateBar.b_Drag && Input.GetMouseButtonUp(0)) { stateBar.b_Drag = false; } #endregion #region LineScrollBar if (lineScrollbar.b_Drag && !Input.GetMouseButtonUp(0)) { lineScrollbar.DragLine(ref ray); } else if (lineScrollbar.b_Drag && Input.GetMouseButtonUp(0)) { lineScrollbar.b_Drag = false; } #endregion #region UI_Line위의 타임라인 바 if (audioSource.clip != null) { if (audioSource.isPlaying) { lineMgr.UpdateLine(audioSource.time, audioSource.clip.length); stateBar.MoveCurPosBar(audioSource.clip.length, audioSource.time); } else { lineMgr.UpdateLine(tempTime, audioSource.clip.length); stateBar.MoveCurPosBar(audioSource.clip.length, tempTime); } } #endregion #region 구간반복 if (b_readyRepeat) { if (Input.GetKeyDown(KeyCode.Escape)) { Destroy(GameObject.Find("RepeatRange")); b_readyRepeat = false; b_startRepeat = false; ButtonManager.b_Repeating = false; } if (!b_startRepeat) { Vector2 offset = ray.origin - startPos; repeatRange.transform.localScale = new Vector3(offset.x, repeatRange.transform.localScale.y, 1); } } if (ButtonManager.b_Repeating) { // UI_StateBar 전체 길이 float standard = StatusBar.endPos.x - StatusBar.startPos.x; // 반복 구간 마지막 위치 float repeatEndPosX = (endPos.x - StatusBar.startPos.x) / standard * audioSource.clip.length; if (audioSource.time > repeatEndPosX) { audioSource.time = (startPos.x - StatusBar.startPos.x) / standard * audioSource.clip.length; } } #endregion }