// Update is called once per frame private void Update() { ++_frames; float timeNow = Time.realtimeSinceStartup; if (Context.IsReady) { if (timeNow > _lastInterval + UpdateInterval) { _fps = (float)(_frames / (timeNow - _lastInterval)); _frames = 0; _lastInterval = timeNow; AverageFps.text = '\u00D8' + " FPS: " + _fps; Debug.Log('\u00D8' + " FPS: " + _fps); } Context.CollisionTextureRenderer.UpdateDepthTexture(); Context.WindManager.Update(); //Context.ProceduralWind.Update(); //Context.WindFieldRenderer.Update(); Context.PatchContainer.Draw(); //Context.BillboardTexturePatchContainer.Draw(); } for (int i = 0; i < _switchSimulationTexture.Length; i++) { if (Input.GetKeyDown(_switchSimulationTexture[i])) { _simulationTextureResolution = (int)Mathf.Pow(2, 3 + i); UpdateDebugInfo("Set SimulationTexture Resolution to " + _simulationTextureResolution); } } for (int i = 0; i < _testSettings.Length; i++) { if (Input.GetKeyDown(_testSettings[i])) { LoadTestSettings(i); } } if (Input.GetKeyDown(_printDebugInfo)) { UpdateDebugInfo(Context.PrintDebugInfo(), 30f); } if (Input.GetKeyDown(_toggleBlossoms)) { UpdateDebugInfo(Context.BladeContainer.Blades[0].HasBlossom ? "Deactivate Blossoms" : "Activate Blossoms"); Context.BladeContainer.Blades[0].HasBlossom = !Context.BladeContainer.Blades[0].HasBlossom; } if (Input.GetKeyDown(_forceBlossoms)) { if (!Context.BladeContainer.Blades[0].HasBlossom) { if (Context.BlossomCount == 0) { UpdateDebugInfo("Force Blossoms rendering."); Context.BlossomCount = 1; } else { UpdateDebugInfo("Deactivate force Blossoms rendering."); Context.BlossomCount = 0; } } else { UpdateDebugInfo("Cannot Force Blossoms because there are blossoms."); } } if (Input.GetKeyDown(_toggleDebugColors)) { _debugColors = !_debugColors; Shader.SetGlobalInt("RenderDebugColor", _debugColors ? 1 : 0); } if (Input.GetKeyDown(_toggleTerrain)) { FindObjectOfType <Terrain>().enabled = !FindObjectOfType <Terrain>().enabled; } if (Input.GetKeyDown(_switchCamera)) { if (!Context.Camera.GetComponent <Animator>().enabled) { _cameraBackupPos = Context.Camera.transform.position; _cameraBackupRot = Context.Camera.transform.rotation; } else { Context.Camera.transform.position = _cameraBackupPos; Context.Camera.transform.rotation = _cameraBackupRot; } Context.Camera.GetComponent <Animator>().enabled = !Context.Camera.GetComponent <Animator>().enabled; } if (Input.GetKeyDown(_switchGrassMapInput)) { if (Context.GrassMapInput.GetType() == typeof(RandomGrassMapInput)) { UpdateDebugInfo("Switch to Texture GrassMap Input"); Context.GrassMapInput = _textureGrassMapInput; Context.GrassMapInputType.Type = _textureGrassMapInputType; } else { UpdateDebugInfo("Switch to Uniform GrassMap Input"); _textureGrassMapInput = Context.GrassMapInput; _textureGrassMapInputType = Context.GrassMapInputType; Context.GrassMapInput = Activator.CreateInstance(typeof(RandomGrassMapInput)) as RandomGrassMapInput; Context.GrassMapInputType.Type = typeof(RandomGrassMapInput); } } }