Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    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:
    32
    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:
    1,195
    Use guiText.color = Color.yellow rather than setting it in the material?
     
    karl_jones likes this.