0

I am trying to make a FlappyBird on WebGL with Unity. I made scores system, and there is no bug finded while runing on unity editor, but when I build with WebGL, Text don't shows up. Only legacy Text (Not TextMeshPro) causes this problm, so it would be helpful too if there is a way to use TextMeshPro. https://r0k0r.github.io/FlappyBirdWebGL is my game link, and https://github.com/R0K0R/FlappyBirdWebGL is my github link. I don't know this will help, but I am currently coding with ubuntu.

this is my Score.cs code that returns current score:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Score : MonoBehaviour
{
    public static int score = 0;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    void OnTriggerEnter2D(){
        score++;
    }

    public static int returnScore(){return score;}
}

and this is my ApplyScore.cs code that applys score to text gameobject.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ApplyScore : MonoBehaviour
{

    public Text ScoreText;

    // Start is called before the first frame update
    void Start()
    {
        ScoreText.text = "0";
    }

    // Update is called once per frame
    void Update()
    {
        ScoreText.text = Score.returnScore().ToString();
    }
}

this is what it looks like

this is what it looks like

and this is what it should look like

and this is what it should look like

Raptor
  • 53,206
  • 45
  • 230
  • 366
R0K0R lee
  • 21
  • 5
  • Show relevant codes and screenshots please. – Raptor May 04 '22 at 06:23
  • Try setting your dev play window size to the same as your webgl window. I expect the text falls just off the top – BugFinder May 04 '22 at 07:27
  • sorry, but tht didn't help.. – R0K0R lee May 04 '22 at 07:40
  • It's probably because your text is out of the display area just like @BugFinder said. Try to move the text closer to center and retry. – Raptor May 04 '22 at 07:48
  • um.. my WebGL build resolution is 1280x720, and I changed my deb play window size to 1280x720 and nothing changed – R0K0R lee May 04 '22 at 07:56
  • Well you haven’t given anything like a way to reproduce it. Only a picture that its happened. We can’t guess everything – BugFinder May 04 '22 at 12:24
  • Have you checked the anchoring of the ui element? Anchor it dead center. If it still does not show up, then it must be something other than positioning. Are you setting the alpha to 0, disabling the gameobject, or something similar? I have used TMP in webgl a number of times with no problem. – hijinxbassist May 04 '22 at 21:53
  • Have you tried to change the Vertical and Horizontal Overflow options to Overflow and increased the fontsize? From your screen, you are using a Free Aspect on Unity, you could try to force it to be the target resolution also to better see what is going on. – Yvens Rebouças Serpa Sep 02 '22 at 05:00

0 Answers0