Search Unity

  1. Tune in to get all the latest Unity news live from Berlin on June 19, 6pm CEST. Set up a YouTube reminder!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Entire canvas is yellow after running an FPS script.

Discussion in 'Scripting' started by pilchardDev, Sep 13, 2017.

  1. pilchardDev

    pilchardDev

    Joined:
    Aug 20, 2016
    Posts:
    40
    Hello, I've pulled an FPS counter script from ' http://wiki.unity3d.com/index.php?title=FramesPerSecond ' (I've slightly modified it for my use.)

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4. public class HUDFPS : MonoBehaviour
    5. {
    6. public  float updateInterval = 0.5F;
    7. private float accum   = 0;
    8. private int   frames  = 0;
    9. private float timeleft;
    10.  
    11. public Text guiText;
    12. void Start()
    13. {
    14.     guiText = this.GetComponent<Text>();
    15.     timeleft = updateInterval;
    16. }
    17. void Update()
    18. {
    19.     timeleft -= Time.deltaTime;
    20.     accum += Time.timeScale/Time.deltaTime;
    21.     ++frames;
    22.     if( timeleft <= 0.0 )
    23.     {
    24.     float fps = accum/frames;
    25.     string format = System.String.Format("{0:F2} FPS",fps);
    26.     guiText.text = format;
    27.     if(fps < 30)
    28.         guiText.material.color = Color.yellow;
    29.     else
    30.         if(fps < 10)
    31.             guiText.material.color = Color.red;
    32.         else
    33.             guiText.material.color = Color.green;
    34.         timeleft = updateInterval;
    35.         accum = 0.0F;
    36.         frames = 0;
    37.     }
    38. }
    39. }
    Ever since I ran this script, everything on my canvas has a yellow tint. Anyone able to explain this, and give me a lead on out to fix it? Thankyou :)

    Kind Regards, Lachlan
     
  2. Peter77

    Peter77

    Joined:
    Jun 12, 2013
    Posts:
    2,231
    Use guiText.color = Color.yellow rather than setting it in the material?
     
    karl_jones likes this.