Skip to content

Commit

Permalink
Implemente --hide-ui option
Browse files Browse the repository at this point in the history
  • Loading branch information
keijiro committed Aug 1, 2024
1 parent ceee8d5 commit 92c3b9c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
20 changes: 20 additions & 0 deletions Assets/ArgParser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Nsm {

sealed class ArgParser
{
public bool HasSource => !string.IsNullOrEmpty(Source);
public string Source { get; private set; }
public bool HideUI { get; private set; }

public ArgParser()
{
var args = System.Environment.GetCommandLineArgs();
for (var i = 1; i < args.Length; i++)
if (i < args.Length - 1 && args[i] == "--source")
Source = args[++i];
else if (args[i] == "--hide-ui")
HideUI = true;
}
}

} // namespace Nsm
2 changes: 2 additions & 0 deletions Assets/ArgParser.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 4 additions & 14 deletions Assets/SourceSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@

namespace Nsm {

sealed class ArgsParser
{
public bool HasSource => !string.IsNullOrEmpty(Source);
public string Source { get; private set; }

public ArgsParser()
{
var args = System.Environment.GetCommandLineArgs();
for (var i = 1; i < args.Length - 1; i++)
if (args[i] == "--source") Source = args[i + 1];
}
}

public sealed class SourceSelector : MonoBehaviour
{
#region Data source accessor for UI
Expand Down Expand Up @@ -85,12 +72,15 @@ void Start()
UISelector.dataSource = this;
UISelector.RegisterValueChangedCallback(e => SelectSource(e.newValue));

var args = new ArgsParser();
var args = new ArgParser();

if (args.HasSource)
SelectSource(UISelector.value = args.Source);
else if (PlayerPrefs.HasKey(PrefKey))
SelectSource(UISelector.value = PlayerPrefs.GetString(PrefKey));

if (args.HideUI) ToggleUI();

#if UNITY_IOS && !UNITY_EDITOR
Application.targetFrameRate = 60;
#endif
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ PlayerSettings:
loadStoreDebugModeEnabled: 0
visionOSBundleVersion: 1.0
tvOSBundleVersion: 1.0
bundleVersion: 0.1
bundleVersion: 2.1.0
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down

0 comments on commit 92c3b9c

Please sign in to comment.