Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Help for text display

Discussion in 'Scripting' started by antoinestpierredev, Sep 27, 2020.

  1. antoinestpierredev

    antoinestpierredev

    Joined:
    Sep 26, 2020
    Posts:
    1
    Hello, I want to write the number of FPS on the scene. I write :

    Code (CSharp):
    1. GUI.Label(new Rect(8, 8, 120, 32), String.Format("FPS {0}", (int)1.0f/Time.smoothDeltaTime));
    in the method 'void OnGUI()', but when I launch my game the text doesn't display I don't understand :/
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    First add a
    Debug.Log("This code is running!");
    call to your OnGUI function to make sure it's actually running.

    If you can confirm that it's running... maybe it's black text on a black screen (or white on white)?
     
  3. Poooiu

    Poooiu

    Joined:
    Oct 4, 2015
    Posts:
    4
    I tried it and it is showing up on the screen, but it is really small. Your code covers (rect, text), but it has no style. Try to define font size, by
    style.fontSize
    It should help.