public override void UpdateInput()
    {
        if (options == null)
        {
            options = GameOption.Get <SpaceshipOptions>();
        }

        SpaceshipOptions.FPSKeys keys = options.fpsKeys;

        m_Movement = new Vector2(Input.GetAxisRaw(MovementHorizontalAxis), Input.GetAxisRaw(MovementVerticalAxis));

        if (m_Movement.magnitude < MovementDeadZone)
        {
            m_Movement = Vector2.zero;
        }

        m_Movement.x += (Input.GetKey(keys.left) ? -1 : 0) + (Input.GetKey(keys.right)   ? 1 : 0);
        m_Movement.y += (Input.GetKey(keys.back) ? -1 : 0) + (Input.GetKey(keys.forward) ? 1 : 0);

        float mag = m_Movement.sqrMagnitude;

        if (mag > 1)
        {
            m_Movement.Normalize();
        }

        Vector2 l = new Vector2(Input.GetAxisRaw(LookHorizontalAxis), Input.GetAxisRaw(LookVerticalAxis));

        m_Look  = l.normalized * Mathf.Pow(Mathf.Clamp01(Mathf.Clamp01(l.magnitude) - LookDeadZone) / (1.0f - LookDeadZone), LookExponent);
        m_Look += new Vector2(Input.GetAxisRaw(MouseHorizontalAxis), Input.GetAxisRaw(MouseVerticalAxis));
    }
    public override void Execute(GameObject instigator = null)
    {
        GraphicOption    go   = GameOption.Get <GraphicOption>();
        SpaceshipOptions o    = GameOption.Get <SpaceshipOptions>();
        float            p    = o.screenPercentage / 100f;
        float            mPix = (go.width * p * go.height * p) / 1000000;
        string           sp   = o.screenPercentage == 100 ? $"Native" : $"{o.screenPercentage}% SP ({o.upsamplingMethod.ToString()})";

        FPSManager fpsm = Manager.Get <FPSManager>();

        QualityText.text          = $"{go.width}x{go.height}@{go.refreshRate}Hz ({go.fullScreenMode}) {sp} ({mPix.ToString("F2", System.Globalization.CultureInfo.InvariantCulture)} MPix) - {QualitySettings.names[QualitySettings.GetQualityLevel()]} Quality";
        OverallFPSText.text       = (1000 / fpsm.results.avgMs).ToString("F1", System.Globalization.CultureInfo.InvariantCulture);
        OverallMSText.text        = fpsm.results.avgMs.ToString("F2", System.Globalization.CultureInfo.InvariantCulture);
        OverallMSPerMPixText.text = (fpsm.results.avgMs / mPix).ToString("F2", System.Globalization.CultureInfo.InvariantCulture);
        WorstFPSText.text         = (1000 / fpsm.results.maxMs).ToString("F1", System.Globalization.CultureInfo.InvariantCulture);
        WorstMSText.text          = fpsm.results.maxMs.ToString("F2", System.Globalization.CultureInfo.InvariantCulture);
        BestFPSText.text          = (1000 / fpsm.results.minMs).ToString("F1", System.Globalization.CultureInfo.InvariantCulture);
        BestMSText.text           = fpsm.results.minMs.ToString("F2", System.Globalization.CultureInfo.InvariantCulture);
        CPUInfo.text = $"{SystemInfo.processorType} ({SystemInfo.processorCount} threads) @ { (SystemInfo.processorFrequency/1000f).ToString("F2", System.Globalization.CultureInfo.InvariantCulture)} GHz. ";
        RAMInfo.text = $"System Memory : { SystemInfo.systemMemorySize / 1000}GB";
        GPUInfo.text = $"{ SystemInfo.graphicsDeviceName} ({ SystemInfo.graphicsDeviceType}) { SystemInfo.graphicsMemorySize / 1000}GB VRAM";
    }
Exemple #3
0
    public void EndRecord(bool abort = false)
    {
        recording       = false;
        recordingPaused = false;

        if (abort || timings == null || timings.Count == 0)
        {
            return;
        }

        var currentCulture = System.Globalization.CultureInfo.CurrentCulture;

        System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;

        string frameTimeStr = string.Join(",", timings);

        float med = 0f;
        float min = float.PositiveInfinity;
        float max = float.NegativeInfinity;

        foreach (var time in timings)
        {
            min  = Mathf.Min(time, min);
            max  = Mathf.Max(time, max);
            med += time;
        }

        med /= timings.Count;

        results = new RecordingResults
        {
            minMs = min,
            maxMs = max,
            avgMs = med
        };

        GraphicOption    go   = GameOption.Get <GraphicOption>();
        SpaceshipOptions o    = GameOption.Get <SpaceshipOptions>();
        float            p    = o.screenPercentage / 100f;
        float            mPix = (go.width * p * go.height * p) / 1000000;


        string dateTime        = $"{DateTime.Now.ToLongDateString()} {DateTime.Now.ToShortTimeString()}";
        string operatingSystem = $"{SystemInfo.operatingSystem}";
        string sp = o.screenPercentage == 100 ? $"Native" : $"{o.screenPercentage}% SP ({o.upsamplingMethod.ToString()})";

        string settings   = $"{go.width}x{go.height}@{go.refreshRate}Hz ({go.fullScreenMode}) {sp} ({mPix.ToString("F2")} MegaPixels)- {QualitySettings.names[QualitySettings.GetQualityLevel()]} Quality";
        string bestFPS    = $"{(1000 / min).ToString("F1")}fps ({min.ToString("F2")}ms)";
        string worstFPS   = $"{(1000 / max).ToString("F1")}fps ({max.ToString("F2")}ms)";
        string averageFPS = $"{(1000 / med).ToString("F1")}fps ({med.ToString("F2")}ms)";
        string msPerMPix  = $"{(med/mPix).ToString("F2")} ms/MPix";

        string systemInfo = $"{SystemInfo.deviceModel}";
        string cpuInfo    = $" {SystemInfo.processorType} ({SystemInfo.processorCount} threads) @ {(SystemInfo.processorFrequency / 1000f).ToString("F2")} GHz.";
        string gpuInfo    = $"{SystemInfo.graphicsDeviceName}({SystemInfo.graphicsDeviceType}) {SystemInfo.graphicsMemorySize / 1000}GB VRAM";
        string memInfo    = $"{SystemInfo.systemMemorySize / 1000}GB.";


#if UNITY_STANDALONE && !UNITY_EDITOR
        try
        {
            string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string spaceshipPath   = Path.Combine(myDocumentsPath, "Spaceship Demo");

            if (!Directory.Exists(spaceshipPath))
            {
                Directory.CreateDirectory(spaceshipPath);
            }

            var writer = new StreamWriter($"{spaceshipPath}/{HTMLPath}");
            writer.Write(@$ "<html>
<head>
    <link href=" "https://cdnjs.cloudflare.com/ajax/libs/c3/0.7.20/c3.css" " rel=" "stylesheet" ">
    <link rel=" "preconnect" " href=" "https://fonts.gstatic.com" ">
    <link href=" "https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" " rel=" "stylesheet" ">
    <script src=" "https://cdnjs.cloudflare.com/ajax/libs/d3/5.16.0/d3.min.js" " charset=" "utf-8" " ></script>
    <script src=" "https://cdnjs.cloudflare.com/ajax/libs/c3/0.7.20/c3.min.js" "></script>
<style>
h1, h2, h3, h4, h5, body, p
{{
font-family: 'Roboto', sans-serif;
}}
</style>
</head>
<body>
<h1> Spaceship - Benchmark Results</h1>
<b>Average FPS : </b> {averageFPS} <br/>