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");
        }
        public string GetEditorDialogueText()
        {
            var dialogueText = PreviewUI.GetDialogueText(conversation, jumpToSpecificEntry ? entryID : -1);

            return("[" + conversation + "] '" + dialogueText + "'");
        }
Пример #3
0
 public string GetEditorBarkText()
 {
     return(useConversation
         ? ("[" + conversation + "] '" + PreviewUI.GetDialogueText(conversation, -1) + "'")
         : text);
 }