/// <inheritdoc/> protected override void OnMessageReceived(IncomingMessage msg) { var key = msg.ReadString(); var value = msg.ReadFloat32(); m_FloatProperties[key] = value; Action <float> action; m_RegisteredActions.TryGetValue(key, out action); action?.Invoke(value); }
/// <inheritdoc/> public override void OnMessageReceived(IncomingMessage msg) { var width = msg.ReadInt32(); var height = msg.ReadInt32(); var qualityLevel = msg.ReadInt32(); var timeScale = msg.ReadFloat32(); var targetFrameRate = msg.ReadInt32(); timeScale = Mathf.Clamp(timeScale, 1, 100); Screen.SetResolution(width, height, false); QualitySettings.SetQualityLevel(qualityLevel, true); Time.timeScale = timeScale; Time.captureFramerate = 60; Application.targetFrameRate = targetFrameRate; }
/// <inheritdoc/> protected override void OnMessageReceived(IncomingMessage msg) { var key = msg.ReadString(); var type = msg.ReadInt32(); if ((int)EnvironmentDataTypes.Float == type) { var value = msg.ReadFloat32(); m_Parameters[key] = value; Action <float> action; m_RegisteredActions.TryGetValue(key, out action); action?.Invoke(value); } else { Debug.LogWarning("EnvironmentParametersChannel received an unknown data type."); } }
/// <inheritdoc/> protected override void OnMessageReceived(IncomingMessage msg) { var messageType = (ConfigurationType)msg.ReadInt32(); switch (messageType) { case ConfigurationType.ScreenResolution: var width = msg.ReadInt32(); var height = msg.ReadInt32(); Screen.SetResolution(width, height, false); break; case ConfigurationType.QualityLevel: var qualityLevel = msg.ReadInt32(); QualitySettings.SetQualityLevel(qualityLevel, true); break; case ConfigurationType.TimeScale: var timeScale = msg.ReadFloat32(); timeScale = Mathf.Clamp(timeScale, 1, 100); Time.timeScale = timeScale; break; case ConfigurationType.TargetFrameRate: var targetFrameRate = msg.ReadInt32(); Application.targetFrameRate = targetFrameRate; break; case ConfigurationType.CaptureFrameRate: var captureFrameRate = msg.ReadInt32(); Time.captureFramerate = captureFrameRate; break; default: Debug.LogWarning( "Unknown engine configuration received from Python. Make sure" + " your Unity and Python versions are compatible."); break; } }