// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties. public override void ProcessFrame(Playable playable, FrameData info, object playerData) { int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); if (inputWeight > 0.001f && !played.Contains(i)) { played.Add(i); if (Application.isPlaying) { DialogueManager.instance.BroadcastMessage("OnConversationContinueAll", SendMessageOptions.DontRequireReceiver); } else { PreviewUI.ShowMessage("Continue", 3, -1); } } else if (inputWeight <= 0.001f && played.Contains(i)) { played.Remove(i); } } }
// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties. public override void ProcessFrame(Playable playable, FrameData info, object playerData) { int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); if (inputWeight > 0.001f && !played.Contains(i)) { played.Add(i); ScriptPlayable <ShowAlertBehaviour> inputPlayable = (ScriptPlayable <ShowAlertBehaviour>)playable.GetInput(i); ShowAlertBehaviour input = inputPlayable.GetBehaviour(); var message = input.message; var duration = input.useTextLengthForDuration ? 0 : (float)inputPlayable.GetDuration(); if (Application.isPlaying) { DialogueManager.ShowAlert(message, duration); } else { PreviewUI.ShowMessage(message, duration, -1); } } else if (inputWeight <= 0.001f && played.Contains(i)) { played.Remove(i); } } }
// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties. public override void ProcessFrame(Playable playable, FrameData info, object playerData) { GameObject trackBinding = playerData as GameObject; Transform speaker = (trackBinding != null) ? trackBinding.transform : null; int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); if (inputWeight > 0.001f && !played.Contains(i)) { played.Add(i); ScriptPlayable <PlaySequenceBehaviour> inputPlayable = (ScriptPlayable <PlaySequenceBehaviour>)playable.GetInput(i); PlaySequenceBehaviour input = inputPlayable.GetBehaviour(); var sequence = input.sequence; if (Application.isPlaying) { DialogueManager.PlaySequence(sequence, speaker, input.listener); } else { PreviewUI.ShowMessage(sequence, 3, -1); } } else if (inputWeight <= 0.001f && played.Contains(i)) { played.Remove(i); } } }
// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties. public override void ProcessFrame(Playable playable, FrameData info, object playerData) { int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); if (inputWeight > 0.001f && !played.Contains(i)) { played.Add(i); ScriptPlayable <SetQuestStateBehaviour> inputPlayable = (ScriptPlayable <SetQuestStateBehaviour>)playable.GetInput(i); SetQuestStateBehaviour input = inputPlayable.GetBehaviour(); if (Application.isPlaying) { if (input.setQuestState) { QuestLog.SetQuestState(input.quest, input.questState); } if (input.setQuestEntryState) { QuestLog.SetQuestEntryState(input.quest, input.questEntryNumber, input.questEntryState); } } else { var message = string.Empty; if (input.setQuestState) { message = "Set quest " + input.quest + " to " + input.questState; if (input.setQuestEntryState) { message += " and entry #" + input.questEntryNumber + " to " + input.questEntryState; } } else if (input.setQuestEntryState) { message = "Set quest " + input.quest + " entry #" + input.questEntryNumber + " to " + input.questEntryState; } if (!string.IsNullOrEmpty(message)) { PreviewUI.ShowMessage(message, 2, -2); } } } else if (inputWeight <= 0.001f && played.Contains(i)) { played.Remove(i); } } }
// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties. public override void ProcessFrame(Playable playable, FrameData info, object playerData) { GameObject trackBinding = playerData as GameObject; if (!trackBinding) { return; } int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); if (inputWeight > 0.001f && !played.Contains(i)) { played.Add(i); ScriptPlayable <BarkBehaviour> inputPlayable = (ScriptPlayable <BarkBehaviour>)playable.GetInput(i); BarkBehaviour input = inputPlayable.GetBehaviour(); if (Application.isPlaying) { if (input.useConversation) { DialogueManager.Bark(input.conversation, trackBinding.transform, input.listener); } else { DialogueManager.BarkString(input.text, trackBinding.transform, input.listener); } } else { var message = DialogueActor.GetActorName(trackBinding.transform) + " bark: " + input.GetEditorBarkText(); if (input.useConversation) { message += " (may vary)"; } PreviewUI.ShowMessage(message, 2, 1); } } else if (inputWeight <= 0.001f && played.Contains(i)) { played.Remove(i); } } }
private void UpdateLength(string conversation, bool jumpToSpecificEntry, int entryID = -1) { var duration = PreviewUI.GetSequenceDuration(conversation, jumpToSpecificEntry ? entryID : -1); Debug.Log("Best estimate duration: " + duration + "sec"); var clip = TimelineEditor.selectedClip; if (clip == null) { return; } var startConversationClip = clip.asset as StartConversationClip; if (startConversationClip == null) { return; } startConversationClip.SetDuration(duration); }
// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties. public override void ProcessFrame(Playable playable, FrameData info, object playerData) { GameObject trackBinding = playerData as GameObject; if (!trackBinding) { return; } int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); if (inputWeight > 0.001f && !played.Contains(i)) { played.Add(i); ScriptPlayable <StartConversationBehaviour> inputPlayable = (ScriptPlayable <StartConversationBehaviour>)playable.GetInput(i); StartConversationBehaviour input = inputPlayable.GetBehaviour(); if (Application.isPlaying) { if (input.entryID <= 0) { DialogueManager.StartConversation(input.conversation, trackBinding.transform, input.conversant); } else { DialogueManager.StartConversation(input.conversation, trackBinding.transform, input.conversant, input.entryID); } } else { var message = OverrideActorName.GetActorName(trackBinding.transform) + " conversation: " + input.conversant; PreviewUI.ShowMessage(message, 2, 0); } } else if (inputWeight <= 0.001f && played.Contains(i)) { played.Remove(i); } } }
// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties. public override void ProcessFrame(Playable playable, FrameData info, object playerData) { GameObject trackBinding = playerData as GameObject; Transform actorTransform = (trackBinding != null) ? trackBinding.transform : null; int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); if (inputWeight > 0.001f && !played.Contains(i)) { played.Add(i); ScriptPlayable <StartConversationBehaviour> inputPlayable = (ScriptPlayable <StartConversationBehaviour>)playable.GetInput(i); StartConversationBehaviour input = inputPlayable.GetBehaviour(); if (Application.isPlaying) { if (input.jumpToSpecificEntry && input.entryID > 0) { DialogueManager.StartConversation(input.conversation, actorTransform, input.conversant, input.entryID); } else { DialogueManager.StartConversation(input.conversation, actorTransform, input.conversant); } } else { var message = "Conversation (" + DialogueActor.GetActorName(actorTransform) + "->" + DialogueActor.GetActorName(input.conversant) + "): [" + input.conversation + "] '" + input.GetEditorDialogueText() + "' (may vary)"; PreviewUI.ShowMessage(message, 2, 0); } } else if (inputWeight <= 0.001f && played.Contains(i)) { played.Remove(i); } } }
public string GetEditorDialogueText() { var dialogueText = PreviewUI.GetDialogueText(conversation, jumpToSpecificEntry ? entryID : -1); return("[" + conversation + "] '" + dialogueText + "'"); }
private string GetEditorContinueText(Playable playable) { #if UNITY_EDITOR var go = UnityEditor.Selection.activeGameObject; if (go != null) { var director = go.GetComponent <PlayableDirector>(); if (director == null) { director = GameObject.FindObjectOfType <PlayableDirector>(); } if (director == null) { Debug.Log("Select PlayableDirector GameObject to be able to preview bark clip text."); } if (director != null && director.playableAsset != null) { var currentTime = director.time; var timelineAsset = director.playableAsset as TimelineAsset; // Find the latest StartConversationClip up to the current time: double startConversationTime = 0; string conversationTitle = string.Empty; int startingEntryID = -1; foreach (var track in timelineAsset.GetOutputTracks()) { foreach (var clip in track.GetClips()) { if (clip.start > currentTime) { break; } if (clip.asset.GetType() == typeof(StartConversationClip)) { var startConversationClip = clip.asset as StartConversationClip; startConversationTime = clip.start; conversationTitle = startConversationClip.template.conversation; startingEntryID = startConversationClip.template.jumpToSpecificEntry ? startConversationClip.template.entryID : -1; } } } // Count how many continues have passed since last StartConversationClip: int numContinues = 0; foreach (var track in timelineAsset.GetOutputTracks()) { foreach (var clip in track.GetClips()) { if (clip.start > currentTime) { break; } if (clip.start > startConversationTime && clip.asset.GetType() == typeof(ContinueConversationClip)) { numContinues++; } } } var dialogueText = PreviewUI.GetDialogueText(conversationTitle, startingEntryID, numContinues); //Debug.Log(numContinues + " continues since " + conversationTitle + " entry " + startingEntryID + // " started at " + startConversationTime + ": " + dialogueText); if (!string.IsNullOrEmpty(dialogueText)) { return(dialogueText + " (may vary)"); } } } #endif return("Continue"); }
// NOTE: This function is called at runtime and edit time. Keep that in mind when setting the values of properties. public override void ProcessFrame(Playable playable, FrameData info, object playerData) { int inputCount = playable.GetInputCount(); for (int i = 0; i < inputCount; i++) { float inputWeight = playable.GetInputWeight(i); if (inputWeight > 0.001f && !played.Contains(i)) { played.Add(i); var inputPlayable = (ScriptPlayable <ContinueConversationBehaviour>)playable.GetInput(i); ContinueConversationBehaviour input = inputPlayable.GetBehaviour(); if (Application.isPlaying) { switch (input.operation) { case ContinueConversationBehaviour.Operation.Continue: DialogueManager.instance.BroadcastMessage("OnConversationContinueAll", SendMessageOptions.DontRequireReceiver); break; case ContinueConversationBehaviour.Operation.ClearSubtitleText: var standardDialogueUI = DialogueManager.dialogueUI as StandardDialogueUI; if (standardDialogueUI != null) { if (input.clearAllPanels) { for (int j = 0; j < standardDialogueUI.conversationUIElements.subtitlePanels.Length; j++) { if (standardDialogueUI.conversationUIElements.subtitlePanels[j] == null) { continue; } standardDialogueUI.conversationUIElements.subtitlePanels[j].ClearText(); } } else if (0 <= input.clearPanelNumber && input.clearPanelNumber < standardDialogueUI.conversationUIElements.subtitlePanels.Length && standardDialogueUI.conversationUIElements.subtitlePanels[input.clearPanelNumber] != null) { standardDialogueUI.conversationUIElements.subtitlePanels[input.clearPanelNumber].ClearText(); } } break; } } else { switch (input.operation) { case ContinueConversationBehaviour.Operation.Continue: PreviewUI.ShowMessage(GetEditorContinueText(playable), 3, -1); break; case ContinueConversationBehaviour.Operation.ClearSubtitleText: break; } } } else if (inputWeight <= 0.001f && played.Contains(i)) { played.Remove(i); } } }
public string GetEditorBarkText() { return(useConversation ? ("[" + conversation + "] '" + PreviewUI.GetDialogueText(conversation, -1) + "'") : text); }
private void UpdateLength(ContinueConversationBehaviour.Operation operation) { if (operation != ContinueConversationBehaviour.Operation.Continue) { return; } var timelineAsset = TimelineEditor.inspectedAsset; var currentTime = TimelineEditor.selectedClip.start; // Find the latest StartConversationClip up to the current time: double startConversationTime = 0; string conversationTitle = string.Empty; int startingEntryID = -1; foreach (var track in timelineAsset.GetOutputTracks()) { foreach (var clip in track.GetClips()) { if (clip.start > currentTime) { break; } if (clip.asset.GetType() == typeof(StartConversationClip)) { var startConversationClip = clip.asset as StartConversationClip; startConversationTime = clip.start; conversationTitle = startConversationClip.template.conversation; startingEntryID = startConversationClip.template.jumpToSpecificEntry ? startConversationClip.template.entryID : -1; } } } // Count how many continues have passed since last StartConversationClip: int numContinues = 0; foreach (var track in timelineAsset.GetOutputTracks()) { foreach (var clip in track.GetClips()) { if (clip.start > currentTime) { break; } if (clip.start > startConversationTime && clip.asset.GetType() == typeof(ContinueConversationClip)) { numContinues++; } } } var duration = PreviewUI.GetSequenceDuration(conversationTitle, startingEntryID, numContinues); Debug.Log("Best estimate duration: " + duration + "sec"); var continueConversationClip = TimelineEditor.selectedClip.asset as ContinueConversationClip; if (continueConversationClip == null) { return; } continueConversationClip.SetDuration(duration); }