Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
using System;
using UnityEngine;
using UnityEngine.UI;

namespace UnityStandardAssets.Utility
{
    [RequireComponent(typeof (Text.))]
    public class FPSCounter : MonoBehaviour
    {
        const float fpsMeasurePeriod = 0.5f;
        private int m_FpsAccumulator = 0;
        private float m_FpsNextPeriod = 0;
        private int m_CurrentFps;
        const string display = "{0} FPS";

        private void Start()
        {
            m_FpsNextPeriod = Time.realtimeSinceStartup + fpsMeasurePeriod;
            m_GuiText.text = GetComponent<Text>();
        }

        private void Update()
        {
            // measure average frames per second
            m_FpsAccumulator++;
            if (Time.realtimeSinceStartup > m_FpsNextPeriod)
            {
                m_CurrentFps = (int) (m_FpsAccumulator/fpsMeasurePeriod);
                m_FpsAccumulator = 0;
                m_FpsNextPeriod += fpsMeasurePeriod;
                m_GuiText.text = string.Format(display, m_CurrentFps);
            }
        }
    }
}


What I have tried:

so im pretty new to unity so bear with me please. I downloaded this assets pack from the unity store and created my scene i am getting this error though and have no idea how to fix it. i have spent hours online trying to figure it out but everything i am trying is not working so i would really greatly appreciate some help. thank you so much! I keep on getting this error : Assets/EgyptAssetPack/Standard Assets/Utility/FPSCounter.cs(8,36): error CS1001: Identifier expected
Posted
Updated 3-Feb-21 11:53am

1 solution

C#
[RequireComponent(typeof (Text.))]

Remove the dot.
Dot in C# is a separator - the system is expecting you to supply a qualified type such as "Text.myclass" which doesn't exist.
C#
[RequireComponent(typeof (Text))]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900