public void StartGameTimer(ConfigVar seconds, string message) { m_TimerStart = (float)Time.ElapsedTime; m_TimerLength = seconds; var gameModeState = EntityManager.GetComponentData <GameModeData>(gameModeEntity); gameModeState.gameTimerMessage.CopyFrom(message); EntityManager.SetComponentData(gameModeEntity, gameModeState); }
void AddSlider(ConfigVar configVar, string description) { var slider = Instantiate(sliderTemplate, content.transform); slider.title.text = description; slider.configVar = configVar; slider.slider.minValue = 0; slider.slider.maxValue = 1; slider.slider.wholeNumbers = false; AddOption(slider); }
public static void RegisterConfigVar(ConfigVar cvar) { if (ConfigVars.ContainsKey(cvar.name)) { GameDebug.LogError("Trying to register cvar " + cvar.name + " twice"); return; } if (!validateNameRe.IsMatch(cvar.name)) { GameDebug.LogError("Trying to register cvar with invalid name: " + cvar.name); return; } ConfigVars.Add(cvar.name, cvar); }
protected override void OnCreate() { FSLog.Info("PreviewClientSimulationSystemGroup OnCreate"); Application.targetFrameRate = 60; UnityEngine.Time.fixedDeltaTime = gameTime.TickInterval; ConfigVar.Init(); ItemCreateUtilities.Init(); ClientCharacterUtilities.Init(); IconUtilities.Init(); GameWorld.Active = new GameWorld(); EntityManager.CreateEntity(typeof(Server)); SetSingleton(new Server()); inputSystem = World.GetOrCreateSystem <InputSystem>(); m_systemsToUpdate.Add(inputSystem); initSystemGroup = World.GetOrCreateSystem <InitSystemGroup>(); m_systemsToUpdate.Add(initSystemGroup); spawnCharacterSystem = World.GetOrCreateSystem <SpawnCharactersSystem>(); m_systemsToUpdate.Add(spawnCharacterSystem); spawnSystemGroup = World.GetOrCreateSystem <SpawnSystemGroup>(); m_systemsToUpdate.Add(spawnSystemGroup); updateReplicatedOwnerFlag = World.GetOrCreateSystem <UpdateReplicatedOwnerFlag>(); m_systemsToUpdate.Add(updateReplicatedOwnerFlag); predictUpdateSystem = World.GetOrCreateSystem <PredictUpdateSystemGroup>(); m_systemsToUpdate.Add(predictUpdateSystem); serverSystemGroup = World.GetOrCreateSystem <ServerSystemGroup>(); m_systemsToUpdate.Add(serverSystemGroup); predictPresentationSystemGroup = World.GetOrCreateSystem <PredictPresentationSystemGroup>(); m_systemsToUpdate.Add(predictPresentationSystemGroup); despawnSystemGroup = World.GetOrCreateSystem <DespawnSystemGroup>(); m_systemsToUpdate.Add(despawnSystemGroup); addItemComponentSystem = World.GetOrCreateSystem <AddItemComponentSystem>(); m_systemsToUpdate.Add(addItemComponentSystem); addDespawnServerSystem = World.GetOrCreateSystem <AddDespawnServerSystem>(); m_systemsToUpdate.Add(addDespawnServerSystem); updateReplicatedOwnerFlag.SetLocalPlayerId(0); }
protected override void OnCreate() { ConfigVar.Init(); var commandLineArgs = Environment.GetCommandLineArgs(); foreach (var commandLine in commandLineArgs) { if(commandLine.StartsWith("-Port:")) NetworkConfig.serverPort.Value = commandLine.Substring(6); FSLog.Info($"commandLineArgs:{commandLine}"); } ItemCreateUtilities.Init(); GameWorld.Active = new GameWorld(); UnityEngine.Time.fixedDeltaTime = GameTick.DefaultGameTick.TickInterval; EntityManager.CreateEntity(typeof(Server)); SetSingleton(new Server()); m_systemsToUpdate.Add(World.GetOrCreateSystem<WorldSceneEntitiesSystem>()); networkServerSystem = World.GetOrCreateSystem<NetworkServerSystem>(); m_systemsToUpdate.Add(World.GetOrCreateSystem<ReplicateEntityServerSystem>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<HandleCommandsSystem>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<InitSystemGroup>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<SpawnPlayerServerSystem>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<SpawnRobotsSystem>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<SpawnSystemGroup>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<RegisterEntityToNetwork>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<PrintGameStateSystem>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<RobotsControlSystem>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<UpdateReplicatedOwnerFlag>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<PredictUpdateSystemGroup>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<ServerSystemGroup>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<PredictPresentationSystemGroup>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<DespawnServerSystem>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<DespawnCharacterSystem>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<DespawnItemOwnerSystem>()); m_systemsToUpdate.Add(World.GetOrCreateSystem<DespawnSystem>()); }
void AddDropdown(ConfigVar configVar, string description, List <string> options, List <string> values, string custom = "") { var drop = Instantiate(dropdownTemplate, content.transform); drop.dropdown.ClearOptions(); drop.dropdown.AddOptions(options); if (custom != "") { drop.dropdown.AddOptions(new List <string> { custom }); } drop.title.text = description; drop.values = values; drop.configVar = configVar; AddOption(drop); }
static void InjectAttributeConfigVars() { foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var _class in assembly.GetTypes()) { if (!_class.IsClass) { continue; } foreach (var field in _class.GetFields(System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)) { if (!field.IsDefined(typeof(ConfigVarAttribute), false)) { continue; } if (!field.IsStatic) { GameDebug.LogError("Cannot use ConfigVar attribute on non-static fields"); continue; } if (field.FieldType != typeof(ConfigVar)) { GameDebug.LogError("Cannot use ConfigVar attribute on fields not of type ConfigVar"); continue; } var attr = field.GetCustomAttributes(typeof(ConfigVarAttribute), false)[0] as ConfigVarAttribute; var name = attr.Name != null ? attr.Name : _class.Name.ToLower() + "." + field.Name.ToLower(); var cvar = field.GetValue(null) as ConfigVar; if (cvar != null) { GameDebug.LogError("ConfigVars (" + name + ") should not be initialized from code; just marked with attribute"); continue; } cvar = new ConfigVar(name, attr.Description, attr.DefaultValue, attr.Flags); cvar.ResetToDefault(); RegisterConfigVar(cvar); field.SetValue(null, cvar); } } } // Clear dirty flags as default values shouldn't count as dirtying DirtyFlags = Flags.None; }
protected override void OnCreate() { FSLog.Info("KitchenClientSimulationSystemGroup OnCreate"); ConfigVar.Init(); GameWorld.Active = new GameWorld(); ItemCreateUtilities.Init(); ClientCharacterUtilities.Init(); MenuUtilities.Init(); IconUtilities.Init(); Application.targetFrameRate = 60; UnityEngine.Time.fixedDeltaTime = GameTick.DefaultGameTick.TickInterval; worldSceneEntitiesSystem = World.GetOrCreateSystem <WorldSceneEntitiesSystem>(); m_systemsToUpdate.Add(worldSceneEntitiesSystem); networkSystem = World.GetOrCreateSystem <NetworkClientSystem>(); m_systemsToUpdate.Add(networkSystem); handleTimeSystem = World.GetOrCreateSystem <HandleTimeSystem>(); m_systemsToUpdate.Add(handleTimeSystem); setRenderTimeSystem = World.GetOrCreateSystem <SetRenderTimeSystem>(); m_systemsToUpdate.Add(setRenderTimeSystem); replicateEntitySystemGroup = World.GetOrCreateSystem <ReplicateEntitySystemGroup>(); m_systemsToUpdate.Add(replicateEntitySystemGroup); setPredictTimeSystem = World.GetOrCreateSystem <SetPredictTimeSystem>(); m_systemsToUpdate.Add(setPredictTimeSystem); predictSystem = World.GetOrCreateSystem <PredictSystem>(); m_systemsToUpdate.Add(predictSystem); itemClientSystemGroup = World.GetOrCreateSystem <ItemClientSystemGroup>(); m_systemsToUpdate.Add(itemClientSystemGroup); predictPresentationSystemGroup = World.GetOrCreateSystem <PredictPresentationSystemGroup>(); m_systemsToUpdate.Add(predictPresentationSystemGroup); despawnSystemGroup = World.GetOrCreateSystem <DespawnSystemGroup>(); m_systemsToUpdate.Add(despawnSystemGroup); }
/// <summary> /// A recursive function that walks over the config tree, transforming all key nodes into CVars. /// </summary> /// <param name="obj">The root table of the TOML document.</param> /// <param name="tablePath">For internal use only, the current path to the node.</param> private void ProcessTomlObject(TomlObject obj, string tablePath = "") { if (obj is TomlTable table) // this is a table { foreach (var kvTml in table) { string newPath; if ((kvTml.Value is TomlTable)) { newPath = tablePath + kvTml.Key + TABLE_DELIMITER; } else { newPath = tablePath + kvTml.Key; } ProcessTomlObject(kvTml.Value, newPath); } } else // this is a key, add CVar { // if the CVar has already been registered if (_configVars.TryGetValue(tablePath, out var cfgVar)) { // overwrite the value with the saved one cfgVar.Value = TypeConvert(obj); cfgVar.ValueChanged?.Invoke(cfgVar.Value); } else { //or add another unregistered CVar var cVar = new ConfigVar(tablePath, null, CVar.NONE) { Value = TypeConvert(obj) }; _configVars.Add(tablePath, cVar); } } }
private void Awake() { Instance = this; DontDestroyOnLoad(gameObject); ConfigVar.Init(); Application.targetFrameRate = -1;//default is to have no frame caps var commandLineArgs = new List <string>(System.Environment.GetCommandLineArgs()); #if UNITY_STANDALONE_LINUX || UNITY_SERVER IsHeadless = true; #else IsHeadless = commandLineArgs.Contains("-batchmode"); QualitySettings.vSyncCount = 0;//need to make the target frame rate work even in headless mode #endif InitConsole(IsHeadless, commandLineArgs); if (IsHeadless) { Application.targetFrameRate = 60; } RegisterConsoleCommands(); Console.SetOpen(true); m_StopwatchFrequency = System.Diagnostics.Stopwatch.Frequency; Clock = new System.Diagnostics.Stopwatch(); Clock.Start(); levelManager = new LevelManager(); levelManager.Init(); inputSystem = new InputSystem(); //Instantiate here to avoid making changes to asset file. config = Instantiate((GameConfiguration)Resources.Load("GameConfiguration")); PushCamera(bootCamera); }
void CmdSaveConfig(string[] arguments) { ConfigVar.Save(k_UserConfigFilename); }
public void Awake() { GameDebug.Assert(game == null); DontDestroyOnLoad(gameObject); game = this; m_StopwatchFrequency = System.Diagnostics.Stopwatch.Frequency; m_Clock = new System.Diagnostics.Stopwatch(); m_Clock.Start(); var buildInfo = FindObjectOfType <BuildInfo>(); if (buildInfo != null) { _buildId = buildInfo.buildId; } var commandLineArgs = new List <string>(System.Environment.GetCommandLineArgs()); #if UNITY_STANDALONE_LINUX m_isHeadless = true; #else m_isHeadless = commandLineArgs.Contains("-batchmode"); #endif var consoleRestoreFocus = commandLineArgs.Contains("-consolerestorefocus"); if (m_isHeadless) { #if UNITY_STANDALONE_WIN string consoleTitle; var overrideTitle = ArgumentForOption(commandLineArgs, "-title"); if (overrideTitle != null) { consoleTitle = overrideTitle; } else { consoleTitle = Application.productName + " Console"; } consoleTitle += " [" + System.Diagnostics.Process.GetCurrentProcess().Id + "]"; var consoleUI = new ConsoleTextWin(consoleTitle, consoleRestoreFocus); #elif UNITY_STANDALONE_LINUX var consoleUI = new ConsoleTextLinux(); #else UnityEngine.Debug.Log("WARNING: starting without a console"); var consoleUI = new ConsoleNullUI(); #endif Console.Init(consoleUI); } else { var consoleUI = Instantiate(Resources.Load <ConsoleGUI>("Prefabs/ConsoleGUI")); DontDestroyOnLoad(consoleUI); Console.Init(consoleUI); m_DebugOverlay = Instantiate(Resources.Load <DebugOverlay>("DebugOverlay")); DontDestroyOnLoad(m_DebugOverlay); m_DebugOverlay.Init(); var hdpipe = RenderPipelineManager.currentPipeline as HDRenderPipeline; if (hdpipe != null) { // hdpipe.DebugLayer2DCallback = DebugOverlay.Render; // hdpipe.DebugLayer3DCallback = DebugOverlay.Render3D; } m_GameStatistics = new GameStatistics(); } // If -logfile was passed, we try to put our own logs next to the engine's logfile var engineLogFileLocation = "./logs"; var logfileArgIdx = commandLineArgs.IndexOf("-logfile"); if (logfileArgIdx >= 0 && commandLineArgs.Count >= logfileArgIdx) { engineLogFileLocation = System.IO.Path.GetDirectoryName(commandLineArgs[logfileArgIdx + 1]); } var logName = m_isHeadless ? "game_" + DateTime.UtcNow.ToString("yyyyMMdd_HHmmss_fff") : "game"; GameDebug.Init(engineLogFileLocation, logName); ConfigVar.Init(); Console.EnqueueCommandNoHistory("exec -s " + k_UserConfigFilename); // Default is to allow no frame cap, i.e. as fast as possible if vsync is disabled Application.targetFrameRate = -1; if (m_isHeadless) { Application.targetFrameRate = serverTickRate.IntValue; QualitySettings.vSyncCount = 0; // Needed to make targetFramerate work; even in headless mode #if !UNITY_STANDALONE_LINUX if (!commandLineArgs.Contains("-nographics")) { GameDebug.Log("WARNING: running -batchmod without -nographics"); } #endif } else { RenderSettings.Init(); } // Out of the box game behaviour is driven by boot.cfg unless you ask it not to if (!commandLineArgs.Contains("-noboot")) { Console.EnqueueCommandNoHistory("exec -s " + k_BootConfigFilename); } var forceClientSystem = commandLineArgs.Contains("-forceclientsystems"); if (!m_isHeadless || forceClientSystem) { m_SoundSystem = new SoundSystem(); m_SoundSystem.Init(audioMixer); m_SoundSystem.MountBank(defaultBank); GameObject go = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/ClientFrontend", typeof(GameObject))); UnityEngine.Object.DontDestroyOnLoad(go); clientFrontend = go.GetComponentInChildren <ClientFrontend>(); } sqpClient = new SQP.SQPClient(); GameDebug.Log("FPS Sample initialized"); #if UNITY_EDITOR GameDebug.Log("Build type: editor"); #elif DEVELOPMENT_BUILD GameDebug.Log("Build type: development"); #else GameDebug.Log("Build type: release"); #endif GameDebug.Log("BuildID: " + buildId); GameDebug.Log("Cwd: " + System.IO.Directory.GetCurrentDirectory()); SimpleBundleManager.Init(); GameDebug.Log("SimpleBundleManager initialized"); levelManager = new LevelManager(); levelManager.Init(); GameDebug.Log("LevelManager initialized"); inputSystem = new InputSystem(); GameDebug.Log("InputSystem initialized"); inputSystem.SetVRInput(); // TODO (petera) added Instantiate here to avoid making changes to asset file. // Feels like maybe SO is not really the right tool here. config = Instantiate((GameConfiguration)Resources.Load("GameConfiguration")); GameDebug.Log("Loaded game config"); // Game loops Console.AddCommand("preview", CmdPreview, "Start preview mode"); Console.AddCommand("serve", CmdServe, "Start server listening"); Console.AddCommand("client", CmdClient, "client: Enter client mode. Looking for servers"); Console.AddCommand("boot", CmdBoot, "Go back to boot loop"); Console.AddCommand("connect", CmdConnect, "connect <ip>: Connect to server on ip (default: localhost)"); Console.AddCommand("menu", CmdMenu, "show the main menu"); Console.AddCommand("load", CmdLoad, "Load level"); Console.AddCommand("quit", CmdQuit, "Quits"); Console.AddCommand("screenshot", CmdScreenshot, "Capture screenshot. Optional argument is destination folder or filename."); Console.AddCommand("crashme", (string[] args) => { GameDebug.Assert(false); }, "Crashes the game next frame "); Console.AddCommand("saveconfig", CmdSaveConfig, "Save the user config variables"); Console.AddCommand("loadconfig", CmdLoadConfig, "Load the user config variables"); #if UNITY_STANDALONE_WIN Console.AddCommand("windowpos", CmdWindowPosition, "Position of window. e.g. windowpos 100,100"); #endif Console.SetOpen(true); Console.ProcessCommandLineArguments(commandLineArgs.ToArray()); PushCamera(bootCamera); }
public void TestSetup() { ConfigVar.ResetAllToDefault(); }
/* * THIS CAUSES RANDOM CRASHES * * private static void PreLoadAnimationNodes() * { * // In Editor, convince Burst to JIT compile all Animation UNode types immediately. #if UNITY_EDITOR * var start = UnityEngine.Time.realtimeSinceStartup; * var wasSyncCompile = Menu.GetChecked("Jobs/Burst/Synchronous Compilation"); * Menu.SetChecked("Jobs/Burst/Synchronous Compilation", true); * try * { * var animAssembly = typeof(Unity.Animation.AnimationGraphSystem).Assembly; * var unodeNonGenericTypes = animAssembly.GetTypes().Where(t => * t.IsClass && !t.IsAbstract && !t.IsGenericType && * typeof(Unity.DataFlowGraph.INodeFunctionality).IsAssignableFrom(t)); * var unodeGenericTypesReferencedInData = animAssembly.GetTypes() * .Where(t => !t.IsClass && typeof(Unity.DataFlowGraph.INodeData).IsAssignableFrom(t)) * .Select(t => t * .GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) * .Select(fi => fi.FieldType) * .Where(ft => ft.IsGenericType && ft.GetGenericTypeDefinition() == typeof(Unity.DataFlowGraph.NodeHandle<>)) * .Select(ft => ft.GetGenericArguments()[0]) * .Where(ft => ft.IsGenericType)) * .SelectMany(t => t) * .Distinct(); * * var nodeSet = new Unity.DataFlowGraph.NodeSet(); * * MethodInfo getFunctionality = nodeSet.GetType().GetMethod("GetFunctionality", new System.Type[0]); * foreach (System.Type t in unodeNonGenericTypes.Concat(unodeGenericTypesReferencedInData)) * getFunctionality.MakeGenericMethod(t).Invoke(nodeSet, null); * * nodeSet.Dispose(); * * Debug.Log($"Compilation of Animation UNode types took {UnityEngine.Time.realtimeSinceStartup - start} seconds"); * } * finally * { * Menu.SetChecked("Jobs/Burst/Synchronous Compilation", wasSyncCompile); * } #endif * } */ public void Awake() { GameDebug.Assert(game == null); DontDestroyOnLoad(gameObject); game = this; GameApp.IsInitialized = true; //PreLoadAnimationNodes(); m_StopwatchFrequency = System.Diagnostics.Stopwatch.Frequency; m_Clock = new System.Diagnostics.Stopwatch(); m_Clock.Start(); #if UNITY_EDITOR _buildUnityVersion = InternalEditorUtility.GetFullUnityVersion(); #endif var buildInfo = FindObjectOfType <BuildInfo>(); if (buildInfo != null) { _buildId = buildInfo.buildId; _buildUnityVersion = buildInfo.buildUnityVersion; } var commandLineArgs = new List <string>(System.Environment.GetCommandLineArgs()); // TODO we should only initialize this if we have a graphics device (i.e. non-headless) Overlay.Managed.Initialize(); #if UNITY_STANDALONE_LINUX m_isHeadless = true; #else m_isHeadless = commandLineArgs.Contains("-batchmode"); #endif var noconsole = commandLineArgs.Contains("-noconsole"); var consoleRestoreFocus = commandLineArgs.Contains("-consolerestorefocus"); if (noconsole) { UnityEngine.Debug.Log("WARNING: starting without a console"); var consoleUI = new ConsoleNullUI(); Console.Init(buildId, buildUnityVersion, consoleUI); } else if (m_isHeadless) { #if UNITY_EDITOR Debug.LogError("ERROR: Headless mode not supported in editor"); #endif #if UNITY_STANDALONE_WIN string consoleTitle; var overrideTitle = ArgumentForOption(commandLineArgs, "-title"); if (overrideTitle != null) { consoleTitle = overrideTitle; } else { consoleTitle = Application.productName + " Console"; } consoleTitle += " [" + System.Diagnostics.Process.GetCurrentProcess().Id + "]"; var consoleUI = new ConsoleTextWin(consoleTitle, consoleRestoreFocus); #elif UNITY_STANDALONE_LINUX var consoleUI = new ConsoleTextLinux(); #else UnityEngine.Debug.Log("WARNING: starting without a console"); var consoleUI = new ConsoleNullUI(); #endif Console.Init(buildId, buildUnityVersion, consoleUI); } else { var consoleUI = Instantiate(Resources.Load <ConsoleGUI>("Prefabs/ConsoleGUI")); DontDestroyOnLoad(consoleUI); Console.Init(buildId, buildUnityVersion, consoleUI); m_DebugOverlay = Instantiate(Resources.Load <DebugOverlay>("DebugOverlay")); DontDestroyOnLoad(m_DebugOverlay); m_DebugOverlay.Init(); m_GameStatistics = new GameStatistics(); } // If -logfile was passed, we try to put our own logs next to the engine's logfile // if -logfile was set to "-" we forward our logs to Debug.Log, so that it ends up on stdout. var engineLogFileLocation = "."; var logName = m_isHeadless ? "game_" + DateTime.UtcNow.ToString("yyyyMMdd_HHmmss_fff") : "game"; var logfileArgIdx = commandLineArgs.IndexOf("-logfile"); var forceForwardToDebug = false; if (logfileArgIdx >= 0 && commandLineArgs.Count >= logfileArgIdx) { var logFile = commandLineArgs[logfileArgIdx + 1]; if (logFile == "-") { forceForwardToDebug = true; } else { engineLogFileLocation = System.IO.Path.GetDirectoryName(logFile); } } GameDebug.Init(engineLogFileLocation, logName, forceForwardToDebug); ConfigVar.Init(); // Support -port and -query_port as per Multiplay standard var serverPort = ArgumentForOption(commandLineArgs, "-port"); if (serverPort != null) { Console.EnqueueCommandNoHistory("server.port " + serverPort); } var sqpPort = ArgumentForOption(commandLineArgs, "-query_port"); if (sqpPort != null) { Console.EnqueueCommandNoHistory("server.sqp_port " + sqpPort); } Console.EnqueueCommandNoHistory("exec -s " + k_UserConfigFilename); // Default is to allow no frame cap, i.e. as fast as possible if vsync is disabled Application.targetFrameRate = -1; if (m_isHeadless) { Application.targetFrameRate = serverTickRate.IntValue; QualitySettings.vSyncCount = 0; // Needed to make targetFramerate work; even in headless mode #if !UNITY_STANDALONE_LINUX if (!commandLineArgs.Contains("-nographics")) { GameDebug.Log("WARNING: running -batchmod without -nographics"); } #endif } else { RenderSettings.Init(); } // Out of the box game behaviour is driven by boot.cfg unless you ask it not to if (!commandLineArgs.Contains("-noboot")) { Console.EnqueueCommandNoHistory("exec -s " + k_BootConfigFilename); } if (m_isHeadless) { SoundSystem.Initialize(new SoundSystemNull()); } else { var soundSystem = new SoundSystemBase(); soundSystem.Init(audioMixer); SoundSystem.Initialize(soundSystem); GameObject go = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/ClientFrontend", typeof(GameObject))); UnityEngine.Object.DontDestroyOnLoad(go); clientFrontend = go.GetComponentInChildren <ClientFrontend>(); } sqpClient = new SQP.SQPClient(); GameDebug.Log("A2 initialized"); #if UNITY_EDITOR GameDebug.Log("Build type: editor"); #elif DEVELOPMENT_BUILD GameDebug.Log("Build type: development"); #else GameDebug.Log("Build type: release"); #endif GameDebug.Log("BuildID: " + buildId); GameDebug.Log("Unity: " + buildUnityVersion); GameDebug.Log("Cwd: " + System.IO.Directory.GetCurrentDirectory()); levelManager = new LevelManager(); levelManager.Init(); GameDebug.Log("LevelManager initialized"); GameDebug.Log("InputSystem initialized"); // Game loops Console.AddCommand("serve", CmdServe, "Start server listening"); Console.AddCommand("client", CmdClient, "client: Enter client mode."); Console.AddCommand("thinclient", CmdThinClient, "client: Enter thin client mode."); Console.AddCommand("boot", CmdBoot, "Go back to boot loop"); Console.AddCommand("connect", CmdConnect, "connect <ip>: Connect to server on ip (default: localhost)"); Console.AddCommand("menu", CmdMenu, "show the main menu"); Console.AddCommand("load", CmdLoad, "Load level"); Console.AddCommand("quit", CmdQuit, "Quits"); Console.AddCommand("screenshot", CmdScreenshot, "Capture screenshot. Optional argument is destination folder or filename."); Console.AddCommand("crashme", (string[] args) => { GameDebug.Assert(false); }, "Crashes the game next frame "); Console.AddCommand("saveconfig", CmdSaveConfig, "Save the user config variables"); Console.AddCommand("loadconfig", CmdLoadConfig, "Load the user config variables"); Console.AddCommand("profile", CmdProfile, "Run the profiling for a level"); #if UNITY_STANDALONE_WIN Console.AddCommand("windowpos", CmdWindowPosition, "Position of window. e.g. windowpos 100,100"); #endif Console.SetOpen(true); Console.ProcessCommandLineArguments(commandLineArgs.ToArray()); #if UNITY_IOS // (marton) This is a hack to work around command line arguments not working on iOS if (!Application.isEditor) { Console.EnqueueCommandNoHistory("preview Level_00"); } #endif GameApp.CameraStack.OnCameraEnabledChanged += OnCameraEnabledChanged; GameApp.CameraStack.PushCamera(bootCamera); }
public void Awake() { GameDebug.Log("-- Game Awakeing --"); GameDebug.Assert(game == null); //DontDestroyOnLoad(gameObject); game = this; m_StopwatchFrequency = System.Diagnostics.Stopwatch.Frequency; m_Clock = new System.Diagnostics.Stopwatch(); m_Clock.Start(); var commandLineArgs = new List <string>(System.Environment.GetCommandLineArgs()); var consoleRestoreFocus = commandLineArgs.Contains("-consolerestorefocus"); var consoleUI = Instantiate(Resources.Load <ConsoleGUI>("Prefabs/ConsoleGUI")); DontDestroyOnLoad(consoleUI); Console.Init(consoleUI); m_DebugOverlay = Instantiate(Resources.Load <DebugOverlay>("Prefabs/DebugOverlay")); DontDestroyOnLoad(m_DebugOverlay); m_DebugOverlay.Init(); // If -logfile was passed, we try to put our own logs next to the engine's logfile var engineLogFileLocation = "."; var logfileArgIdx = commandLineArgs.IndexOf("-logfile"); if (logfileArgIdx >= 0 && commandLineArgs.Count >= logfileArgIdx) { engineLogFileLocation = System.IO.Path.GetDirectoryName(commandLineArgs[logfileArgIdx + 1]); } var logName = m_isHeadless ? "game_" + DateTime.UtcNow.ToString("yyyyMMdd_HHmmss_fff") : "game"; GameDebug.Init(engineLogFileLocation, logName); ConfigVar.Init(); #if UNITY_EDITOR GameDebug.Log("Build type: editor"); #elif DEVELOPMENT_BUILD GameDebug.Log("Build type: development"); #else GameDebug.Log("Build type: release"); #endif //GameDebug.Log("BuildID: " + buildId); GameDebug.Log("Cwd: " + System.IO.Directory.GetCurrentDirectory()); // Game loops Console.AddCommand("zero", CmdZero, "Start preview mode"); Console.AddCommand("gameloops", CmdGameLoops, "List all current game loops."); Console.AddCommand("clear", CmdClear, "Shutdown all initilized IGameLoop provided as argument."); Console.AddCommand("reset", CmdResetLoop, "Resets all initilized IGameLoop provided as argument."); // Utility commands Console.AddCommand("quit", CmdQuit, "Quits"); Console.AddCommand("screenshot", CmdScreenshot, "Capture screenshot. Optional argument is destination folder or filename."); Console.AddCommand("crashme", (string[] args) => { GameDebug.Assert(false); }, "Crashes the game next frame "); #if UNITY_STANDALONE_WIN Console.AddCommand("windowpos", CmdWindowPosition, "Position of window. e.g. windowpos 100,100"); #endif Console.SetOpen(true); Console.ProcessCommandLineArguments(commandLineArgs.ToArray()); if (k_BootConfigFilename != null) { Console.EnqueueCommandNoHistory("exec -s " + k_BootConfigFilename); } GameDebug.Log("-- Game Awake --"); }
public void Setup() { ConfigVar.Init(); }
public void StartGameTimer(ConfigVar seconds, string message) { m_TimerStart = Time.time; m_TimerLength = seconds; gameModeState.gameTimerMessage = message; }