using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class ConsoleTest : MonoBehaviour { [SerializeField] private MissionPack baseGame = MissionPack.Quake; [SerializeField] private string mod, args; [SerializeField] private Camera mainCamera; [SerializeField] private List visualStyles = new List(); private UniQuake uq; private void Start() { Debug.Log($"Running in {IntPtr.Size * 8}-bit mode"); #if UNITY_PS5 || UNITY_GAMECORE_SCARLETT Application.targetFrameRate = 120; Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height, true, 120); #endif uq = gameObject.AddComponent(); uq.BaseGame = baseGame; uq.ModDirectory = mod; uq.AdditionalArguments = ParseArgs(); uq.Camera = mainCamera; uq.GameLayer = Layers.Game1; uq.ViewModelLayer = Layers.ViewModel1; uq.SetVisualStyle(visualStyles[0]); } private string[] ParseArgs() { if (args == null) return new string[0]; return args.Split(new[] {' ', '\t', '\r', '\n'}, StringSplitOptions.RemoveEmptyEntries); } private readonly float[] frameTimes = new float[10]; private int frameCount = 0; private float framesPerSecond = float.NaN; private string fpsText; private void Update() { frameTimes[frameCount++] = Time.unscaledDeltaTime; if (frameCount >= frameTimes.Length) { float totalTime = 0f; for (int i = 0; i < frameTimes.Length; ++i) { totalTime += frameTimes[i]; } framesPerSecond = (float)frameCount / totalTime; frameCount = 0; fpsText = $"{framesPerSecond:0.0} fps"; } } private void OnGUI() { int screenHeight = Screen.currentResolution.height; if (screenHeight == 0) screenHeight = 1080; float screenScale = screenHeight / 720f; GUI.matrix = Matrix4x4.Scale(new Vector3(screenScale, screenScale, 1)); if (fpsText != null) GUI.Label(new Rect(10, 10, 1000, 100), fpsText); } }