Search Unity

The code has a parsing error and i don't know why

Discussion in 'Scripting' started by Chaddychops, Jul 6, 2015.

?

how do i fix this

  1. how to fix

    1 vote(s)
    100.0%
  2. fix

    1 vote(s)
    100.0%
Multiple votes are allowed.
  1. Chaddychops

    Chaddychops

    Joined:
    Feb 17, 2015
    Posts:
    1
    using UnityEngine;
    using System.Collections;

    public class FPSDisplay : MonoBehaviour {


    float deltaTime = 0.0f;

    void Update()
    {
    deltaTime += (Time.deltaTime - deltaTime) * 0.1f;
    }

    void OnGUI()
    {
    int w = Screen.width, h = Screen.height;

    GUIStyle style = new GUIStyle();

    Rect rect = new Rect(0, 0, w, h * 2 / 100);
    style.alignment = TextAnchor.UpperLeft;
    style.fontSize = h * 2 / 100;
    style.normal.textColor = new Color (0.0f, 0.0f, 0.5f, 1.0f);
    float msec = deltaTime * 1000.0f;
    float fps = 1.0f / deltaTime;
    string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps);
    GUI.Label(rect, text, style);

    }
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    1) don't use pointless polls,
    2) read the sticky at the top of the scripting section which tells you how to use [code ][ /code] tags,
    3) errors contain line numbers, really helpful if you post the entire error text
     
  3. Boz0r

    Boz0r

    Joined:
    Feb 27, 2014
    Posts:
    419
    Unless you're not posting all the code, your class definition bracket isn't closed.
     
    Kiwasi likes this.