private void DrawTimeLineMenu() { GUILayout.BeginHorizontal(); // Choose file music. GUILayout.Label("File:"); this.m_SoundAudio = (AudioClip)EditorGUILayout.ObjectField(this.m_SoundAudio, typeof(AudioClip)); if (this.m_PreviousAudio != this.m_SoundAudio) { this.m_DictNodeData.Clear(); this.m_PreviousAudio = this.m_SoundAudio; this.m_CurrentSelectedNode = null; } // GUILayout.FlexibleSpace (); // Choose sound file GUILayout.Label(this.m_SoundAudio == null ? "Please choose file audio clip." : "You select file: " + this.m_SoundAudio.name); // Play sound if (GUILayout.Button("Play >>")) { if (this.m_SoundAudio != null) { AudioUtility.PlayClip(this.m_SoundAudio); this.m_PreviousAudio = this.m_SoundAudio; this.m_IsPlaying = true; this.m_IsPause = false; this.m_IsPlayingReview = false; this.m_IsPauseReview = false; } } // Pause or resume sound if (this.m_IsPause == false) { if (GUILayout.Button("Pause ||")) { if (this.m_SoundAudio != null) { AudioUtility.PauseClip(this.m_SoundAudio); this.m_IsPause = true; } } } else { if (GUILayout.Button("Resume ||")) { if (this.m_SoundAudio != null) { AudioUtility.ResumeClip(this.m_SoundAudio); this.m_IsPause = false; } } } GUILayout.EndHorizontal(); }
private void DrawKeyframeMenu() { GUILayout.BeginHorizontal(); if (GUILayout.Button("Add keyframe") && this.m_IsPlayingReview == false) { var nodeTimelineIndex = (int)this.m_SoundTimeLine; var keyName = "Keyframe_" + nodeTimelineIndex; // Create new node var nodeData = CreateNewNode(nodeTimelineIndex); if (this.m_DictNodeData.ContainsKey(keyName)) { // Add new key node in key frame this.m_DictNodeData [keyName].Add(nodeData); } else { // Create new key frame this.m_DictNodeData.Add(keyName, new List <CNodeEditorData> ()); // Add new key node in key frame this.m_DictNodeData [keyName].Add(nodeData); } var listNode = this.m_DictNodeData [keyName]; nodeData.editorIndex = listNode.Count - 1; this.m_CurrentSelectKeyframe = keyName; } if (GUILayout.Button("Delete keyframe") && this.m_IsPlayingReview == false) { if (string.IsNullOrEmpty(this.m_CurrentSelectKeyframe) == false) { if (this.m_DictNodeData.ContainsKey(this.m_CurrentSelectKeyframe)) { this.m_DictNodeData [this.m_CurrentSelectKeyframe].Clear(); this.m_DictNodeData.Remove(this.m_CurrentSelectKeyframe); this.m_CurrentSelectKeyframe = string.Empty; this.m_CurrentSelectedNode = null; } } } if (GUILayout.Button("Copy keyframe")) { if (string.IsNullOrEmpty(this.m_CurrentSelectKeyframe) == false) { if (this.m_DictNodeData.ContainsKey(this.m_CurrentSelectKeyframe)) { var keyframes = this.m_DictNodeData [this.m_CurrentSelectKeyframe]; this.m_CurrentTargetKeyframe = keyframes; } } } if (GUILayout.Button("Paste keyframe")) { if (this.m_CurrentTargetKeyframe != null && this.m_CurrentTargetKeyframe.Count > 0) { var nodeTimelineIndex = (int)this.m_SoundTimeLine; var keyName = "Keyframe_" + nodeTimelineIndex; if (this.m_DictNodeData.ContainsKey(keyName)) { // TODO } else { // Create new key frame this.m_DictNodeData.Add(keyName, new List <CNodeEditorData> ()); } for (int i = 0; i < this.m_CurrentTargetKeyframe.Count; i++) { var tmpNode = this.m_CurrentTargetKeyframe [i]; var newNode = new CNodeEditorData(); newNode.audioTime = nodeTimelineIndex; newNode.nodeType = tmpNode.nodeType; newNode.nodePosition = tmpNode.nodePosition; newNode.nodeScale = tmpNode.nodeScale; this.m_DictNodeData [keyName].Add(newNode); newNode.editorIndex = this.m_DictNodeData [keyName].Count - 1; newNode.editorNodePosition = newNode.nodePosition.ToVector2(); } this.m_CurrentSelectKeyframe = keyName; } } GUILayout.FlexibleSpace(); if (GUILayout.Button(this.m_IsPlayingReview == false ? "Play review" : "Stop review")) { this.m_CurrentSelectKeyframe = string.Empty; this.m_CurrentSelectedNode = null; this.m_IsPlaying = false; this.m_IsPause = false; this.m_IsPlayingReview = !this.m_IsPlayingReview; this.m_IsPauseReview = false; if (this.m_IsPlayingReview) { AudioUtility.StopAllClips(); AudioUtility.PlayClip(this.m_SoundAudio); } else { AudioUtility.StopClip(this.m_SoundAudio); } } if (GUILayout.Button(this.m_IsPauseReview == false ? "Pause review" : "Resume review") && this.m_IsPlayingReview) { this.m_IsPauseReview = !this.m_IsPauseReview; if (this.m_IsPauseReview) { AudioUtility.PauseClip(this.m_SoundAudio); } else { AudioUtility.ResumeClip(this.m_SoundAudio); } } GUILayout.EndHorizontal(); }
private void ResumeClip() { AudioUtility.ResumeClip(audioClip); }