2019年12月

adb devices

    #region    FPS计算

    float fps;
    float deltaTime = 0.0f;
    float msec;
    Rect rect;
    GUIStyle style = new GUIStyle();

    void Start() {
        int w = Screen.width, h = Screen.height;
        rect = new Rect(w - 350, 0, 300, h * 4 / 100);
        style.alignment = TextAnchor.UpperLeft;
        style.fontSize = h * 4 / 100;
        style.normal.textColor = new Color(1.0f, 0.0f, 0f, 1.0f);
    }

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

    void OnGUI() {
        msec = deltaTime * 1000.0f;
        fps = 1.0f / deltaTime;

        GUI.Label(rect, string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps), style);
    }

    #endregion
FPS计算

猜你喜欢

转载自www.cnblogs.com/revoid/p/11967940.html