Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions com.unity.renderstreaming/Editor/ConfigInfoLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ static class Style
private readonly bool m_visibleStatus;
private readonly bool m_skipErrorIcon;
private Func<bool> m_tester;
private Func<bool> m_dependTester;
private bool m_haveFixer;
private bool m_currentStatus;
private bool m_dependStatus;

public ConfigInfoLine(
string label,
Expand All @@ -27,6 +29,7 @@ public ConfigInfoLine(
string resolverButtonLabel,
Func<bool> tester,
Action resolver,
Func<bool> dependTester = null,
bool visibleStatus = true,
bool skipErrorIcon = false
)
Expand All @@ -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"};
Expand Down Expand Up @@ -71,20 +75,24 @@ public ConfigInfoLine(

Add(new HelpBox(error, kind));

UpdateDisplay(m_currentStatus, m_haveFixer);
UpdateDisplay(m_currentStatus, m_haveFixer, m_dependStatus);
}

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_dependStatus;
if (changeConfigured || changeDependConfigured)
{
UpdateDisplay(wellConfigured, m_haveFixer);
UpdateDisplay(wellConfigured, m_haveFixer, wellDependConfigured);
m_currentStatus = wellConfigured;
m_dependStatus = wellDependConfigured;
}
}

private void UpdateDisplay(bool statusOK, bool haveFixer)
private void UpdateDisplay(bool statusOK, bool haveFixer, bool dependStatusOK)
{
if (m_visibleStatus)
{
Expand All @@ -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<Button>(name: "resolver");
resolver.style.display = statusOK || !haveFixer ? DisplayStyle.None : DisplayStyle.Flex;
resolver.SetEnabled(dependStatusOK);
this.Q(className: HelpBox.ussClassName).style.display = statusOK ? DisplayStyle.None : DisplayStyle.Flex;
}
}
Expand Down
31 changes: 28 additions & 3 deletions com.unity.renderstreaming/Editor/RenderStreamingWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -105,13 +109,14 @@ enum Scope
struct Entry
{
public delegate bool Checker();

public delegate void Fixer();
public delegate bool DependChecker();

public readonly Scope scope;
public readonly ConfigStyle configStyle;
public readonly Checker check;
public readonly Fixer fix;
public readonly DependChecker dependChecker;
public readonly bool forceDisplayCheck;
public readonly bool skipErrorIcon;

Expand All @@ -120,6 +125,7 @@ public Entry(
ConfigStyle configStyle,
Checker check,
Fixer fix,
DependChecker dependChecker = null,
bool forceDisplayCheck = false,
bool skipErrorIcon = false
)
Expand All @@ -128,6 +134,7 @@ public Entry(
this.configStyle = configStyle;
this.check = check;
this.fix = fix;
this.dependChecker = dependChecker;
this.forceDisplayCheck = forceDisplayCheck;
this.skipErrorIcon = skipErrorIcon;
}
Expand All @@ -144,12 +151,15 @@ 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),
FixInputSystemBackgroundBehavior,
IsInputSettingsAssetsExists),
new Entry(Scope.PlayMode, inputSystemPlayModeInputBehavior,
IsInputSystemPlayModeInputBehaviorCorrect,
FixInputSystemPlayModeInputBehavior),
FixInputSystemPlayModeInputBehavior,
IsInputSettingsAssetsExists),
new Entry(Scope.BuildSettings, currentBuildTarget, IsSupportedBuildTarget, FixSupportedBuildTarget),
new Entry(Scope.BuildSettings, currentGraphicsApi, IsSupportedGraphics, FixSupportedGraphics),
new Entry(Scope.BuildSettings, macCameraUsageDescription, IsMacCameraUsageCorrect, FixMacCameraUsage),
Expand All @@ -174,6 +184,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<InputSettings>();
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;

Expand Down Expand Up @@ -510,6 +533,7 @@ private void BindChecker()
entry.configStyle.button,
() => entry.check(),
entry.fix == null ? (Action)null : () => entry.fix(),
entry.dependChecker == null ? (Func<bool>)null : () => entry.dependChecker(),
entry.configStyle.messageType == MessageType.Error || entry.forceDisplayCheck,
entry.skipErrorIcon));
}
Expand All @@ -523,6 +547,7 @@ private void BindChecker()
entry.configStyle.button,
() => entry.check(),
entry.fix == null ? (Action)null : () => entry.fix(),
entry.dependChecker == null ? (Func<bool>)null : () => entry.dependChecker(),
entry.configStyle.messageType == MessageType.Error || entry.forceDisplayCheck,
entry.skipErrorIcon));
}
Expand Down