Home Game Development gui – Freeze/Not interactable participant object when textual content pops up

gui – Freeze/Not interactable participant object when textual content pops up

0
gui – Freeze/Not interactable participant object when textual content pops up

[ad_1]

I’ve a Dialogue system that exhibits up when a scene begins or a participant touches an object. I’m questioning if is it attainable to make the participant freeze/not interactable when dialogue pops up. I do not assume I can use freeze time with Time.timeSacle = 0; since I’m utilizing animation it should freeze the animation and will not play. Is there a workaround this?

This is my Dialogue Manager

utilizing System.Collections;
utilizing System.Collections.Generic;
utilizing UnityEngine;
utilizing UnityEngine.UI;

public class DialogueManager : MonoBehaviour
{
    public Text titleText;
    public Text dialogueText;
    public Animator animator;

    personal Queue<string> sentences;

    public static DialogueManager occasion { get; personal set; }

    personal void Awake()
    {
        occasion = this;    
    }
    // Start is known as earlier than the primary body replace
    void Start()
    {
        
        dialogueText.textual content = string.Empty;
        sentences = new Queue<string>(); 
    }// finish of begin

    public void StartDialogue(Dialogue dialogue)
    {
        animator.SetBool("IsOpen", true);
       // Debug.Log("Starting dialog with " + dialogue.title);
        titleText.textual content = dialogue.title;
        sentences.Clear();  

        foreach(string sentence in dialogue.sentences)
        {
            sentences.Enqueue(sentence);
        }

        DisplaySubsequentSentence();
    }

    public void DisplaySubsequentSentence()
    {
        if(sentences.Count == 0)
        {
            EndDialogue();
            return;
        }

         string sentence = sentences.Dequeue();
         StopAllCoroutines();
         StartCoroutine(KindSentence(sentence));
         

         Debug.Log(sentence);
    }// finish of Display subsequent Sentence

    IEnumerator KindSentence (string sentence)
    {
        float i = 0.07f;
        dialogueText.textual content = "";

        foreach(char letter in sentence.ToCharArray())
        {
            dialogueText.textual content += letter;
            yield return new WaitForSeconds(i);
        }
    }

   void EndDialogue()
    {
        animator.SetBool("IsOpen", false);
        
       // Debug.Log("End Of Conversation");
    }
}

To play the dialogue in a brand new scene I’m simply calling an occasion to Start dialogue and passing my dialogue in it

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here