From 1ea514e9f8ded4b411f79e9be439020767edfb9a Mon Sep 17 00:00:00 2001 From: Takashi KANNAN Date: Fri, 17 Feb 2023 09:24:49 +0900 Subject: [PATCH 1/3] create input settings from wizard --- .../Editor/RenderStreamingWizard.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/com.unity.renderstreaming/Editor/RenderStreamingWizard.cs b/com.unity.renderstreaming/Editor/RenderStreamingWizard.cs index 41e6bf48d..3a4b32851 100644 --- a/com.unity.renderstreaming/Editor/RenderStreamingWizard.cs +++ b/com.unity.renderstreaming/Editor/RenderStreamingWizard.cs @@ -48,6 +48,10 @@ public ConfigStyle(string label, string error, string button = "Fix", label: "Run In Background", error: "Run In Background must be True for Render Streaming to work in Background."); + static readonly ConfigStyle inputSystemSettingsAssets = new ConfigStyle( + label: "Input System Settings Assets", + error: "Input System Settings asset must exist under the Assets folder for changes."); + static readonly ConfigStyle inputSystemBackgroundBehavior = new ConfigStyle( label: "InputSystem Background Behavior", error: "InputSystem Background Behavior must be Ignore Focus for Input System to work in Background."); @@ -144,6 +148,7 @@ Entry[] Entries entries = new[] { new Entry(Scope.PlayMode, runInBackground, IsRunInBackgroundCorrect, FixRunInBackground), + new Entry(Scope.PlayMode, inputSystemSettingsAssets, IsInputSettingsAssetsExists, FixInputSettingsAssets), new Entry(Scope.PlayMode, inputSystemBackgroundBehavior, IsInputSystemBackgroundBehaviorCorrect, FixInputSystemBackgroundBehavior), @@ -174,6 +179,19 @@ Entry[] Entries private static bool IsRunInBackgroundCorrect() => PlayerSettings.runInBackground; private static void FixRunInBackground() => PlayerSettings.runInBackground = true; + private static bool IsInputSettingsAssetsExists() + { + var path = AssetDatabase.GetAssetPath(UnityEngine.InputSystem.InputSystem.settings); + return !string.IsNullOrEmpty(path) && path.StartsWith("Assets/"); + } + + private static void FixInputSettingsAssets() + { + var inputSettings = CreateInstance(); + AssetDatabase.CreateAsset(inputSettings, $"Assets/{PlayerSettings.productName}.inputsettings.asset"); + UnityEngine.InputSystem.InputSystem.settings = inputSettings; + } + private static bool IsInputSystemBackgroundBehaviorCorrect() => UnityEngine.InputSystem.InputSystem.settings.backgroundBehavior == InputSettings.BackgroundBehavior.IgnoreFocus; From 01675f6d28eba31fa490cb95b84e9ada580e5493 Mon Sep 17 00:00:00 2001 From: Takashi KANNAN Date: Fri, 17 Feb 2023 10:06:49 +0900 Subject: [PATCH 2/3] add depend tester --- .../Editor/ConfigInfoLine.cs | 20 ++++++++++++++----- .../Editor/RenderStreamingWizard.cs | 13 +++++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/com.unity.renderstreaming/Editor/ConfigInfoLine.cs b/com.unity.renderstreaming/Editor/ConfigInfoLine.cs index c012563e7..cbcf787a9 100644 --- a/com.unity.renderstreaming/Editor/ConfigInfoLine.cs +++ b/com.unity.renderstreaming/Editor/ConfigInfoLine.cs @@ -17,8 +17,10 @@ static class Style private readonly bool m_visibleStatus; private readonly bool m_skipErrorIcon; private Func m_tester; + private Func m_dependTester; private bool m_haveFixer; private bool m_currentStatus; + private bool m_dependStats; public ConfigInfoLine( string label, @@ -27,6 +29,7 @@ public ConfigInfoLine( string resolverButtonLabel, Func tester, Action resolver, + Func dependTester = null, bool visibleStatus = true, bool skipErrorIcon = false ) @@ -35,6 +38,7 @@ public ConfigInfoLine( m_skipErrorIcon = skipErrorIcon; m_tester = tester; m_haveFixer = resolver != null; + m_dependTester = dependTester; var testLabel = new Label(label) {name = "testLabel"}; var fixer = new Button(resolver) {text = resolverButtonLabel, name = "resolver"}; @@ -71,20 +75,24 @@ public ConfigInfoLine( Add(new HelpBox(error, kind)); - UpdateDisplay(m_currentStatus, m_haveFixer); + UpdateDisplay(m_currentStatus, m_haveFixer, m_dependStats); } public void CheckUpdate() { bool wellConfigured = m_tester(); - if (wellConfigured ^ m_currentStatus) + bool wellDependConfigured = m_dependTester == null || m_dependTester(); + bool changeConfigured = wellConfigured ^ m_currentStatus; + bool changeDependConfigured = wellDependConfigured ^ m_dependStats; + if (changeConfigured || changeDependConfigured) { - UpdateDisplay(wellConfigured, m_haveFixer); + UpdateDisplay(wellConfigured, m_haveFixer, wellDependConfigured); m_currentStatus = wellConfigured; + m_dependStats = wellDependConfigured; } } - private void UpdateDisplay(bool statusOK, bool haveFixer) + private void UpdateDisplay(bool statusOK, bool haveFixer, bool dependStatusOK) { if (m_visibleStatus) { @@ -94,7 +102,9 @@ private void UpdateDisplay(bool statusOK, bool haveFixer) : DisplayStyle.None; } - this.Q(name: "resolver").style.display = statusOK || !haveFixer ? DisplayStyle.None : DisplayStyle.Flex; + var resolver = this.Q