예제 #1
0
        public virtual bool AddOption(string text, Sequence targetSequence)
        {
            gameObject.SetActive(true);

            bool addedOption = false;

            foreach (Button button in cachedButtons)
            {
                if (!button.gameObject.activeSelf)
                {
                    button.gameObject.SetActive(true);

                    Text textComponent = button.GetComponentInChildren <Text>();
                    if (textComponent != null)
                    {
                        textComponent.text = text;
                    }

                    Sequence sequence = targetSequence;

                    button.onClick.AddListener(delegate {
                        StopAllCoroutines();                         // Stop timeout
                        Clear();
                        gameObject.SetActive(false);

                        // Hide the active Say dialog in case it's still being displayed
                        SayDialog activeSayDialog = SetSayDialog.GetActiveSayDialog();
                        if (activeSayDialog != null)
                        {
                            activeSayDialog.ShowDialog(false);
                        }

                        if (sequence != null)
                        {
                                                        #if UNITY_EDITOR
                            // Select the new target sequence in the Fungus Script window
                            FungusScript fungusScript     = sequence.GetFungusScript();
                            fungusScript.selectedSequence = sequence;
                                                        #endif

                            sequence.ExecuteCommand(0);
                        }
                    });

                    addedOption = true;
                    break;
                }
            }

            return(addedOption);
        }
예제 #2
0
        public override void OnEnter()
        {
            if (!showAlways && executionCount >= showCount)
            {
                Continue();
                return;
            }

            executionCount++;

            SayDialog sayDialog = SetSayDialog.GetActiveSayDialog();

            if (sayDialog == null)
            {
                Continue();
                return;
            }

            FungusScript fungusScript = GetFungusScript();

            sayDialog.SetCharacter(character, fungusScript);
            sayDialog.SetCharacterImage(portrait);

            sayDialog.ShowDialog(true);

            if (voiceOverClip != null)
            {
                sayDialog.PlayVoiceOver(voiceOverClip);
            }

            string subbedText = fungusScript.SubstituteVariables(storyText);

            sayDialog.Say(subbedText, waitForInput, delegate {
                if (waitForInput)
                {
                    sayDialog.ShowDialog(false);
                }
                Continue();
            });
        }