public override Playable CreatePlayable(PlayableGraph graph, GameObject owner) { var playable = ScriptPlayable <StartConversationBehaviour> .Create(graph, template); StartConversationBehaviour clone = playable.GetBehaviour(); clone.conversant = conversant.Resolve(graph.GetResolver()); return(playable); }
// 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); } } }