[Question] How to fix Screen Flickering with Auto text Typer Script

Hi,

I am trying to create an auto text typing effect. I have the following code:

// Method to Create Auto Typing Effect
    IEnumerator ShowTypeText(string fullText)
    {
        string currentText;        
        for (int i = 1; i <= fullText.Length; i++)
        {
            currentText = fullText.Substring(0, i);
            mainText.text = currentText;
            yield return new WaitForSeconds(DELAY);
        }        
    }

My update() method:

// Update is called once per frame
    void Update()
    {   
        switch(gameState)
        {
            case GameState.Start_S0: State_S0(); break;
        }        
    }

My State_S0() Method:

private void State_S0()
{
        message = "Some long Message ....  <snipped>";

        StartCoroutine(ShowTypeText(message));

        if (Input.GetKeyDown(KeyCode.C))
        {                
                StartCoroutine(ShowTypeText("State Changed to <snipped>"));            
        }
    }

With my code I get raid screen flickering which is obvious because Update() is called for every frame of the game. So how to fix it?

Anybody else have had this problem?

Would appreciate some cool info on this.

A Solution to this problem was given by @wcoltd here

Privacy & Terms