Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime switching of experimental mode #802

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Assets/Editor/BuildTiltBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ static void ShowBrushExportTextures()
using (var unused = new TempHookUpSingletons())
{
// Set consultUserConfig = false to keep user config from affecting the build output.
TiltBrushManifest manifest = App.Instance.GetMergedManifest(forceExperimental: true);
TiltBrushManifest manifest = App.Instance.ManifestFull;

StringBuilder s = new StringBuilder();
foreach (BrushDescriptor desc in manifest.UniqueBrushes())
Expand Down Expand Up @@ -1547,7 +1547,7 @@ public static void DoBuild(TiltBuildOptions tiltOptions)
// to be run at build-time (ie when nobody has called Start(), Awake()).
// TempHookupSingletons() has done just enough initialization to make it happy.
// Also set consultUserConfig = false to keep user config from affecting the build output.
TiltBrushManifest manifest = App.Instance.GetMergedManifest(forceExperimental: true);
TiltBrushManifest manifest = App.Instance.ManifestFull;

// Some sanity checks
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scenes/Main.unity
Original file line number Diff line number Diff line change
Expand Up @@ -10198,7 +10198,7 @@ MonoBehaviour:
m_FadeFromBlackDuration: 3
m_QuickLoadHintDelay: 2
m_GpuIntersector: {fileID: 165291219}
m_Manifest: {fileID: 11400000, guid: 0be87170c871bfc4f91119634daa9c79, type: 2}
m_ManifestStandard: {fileID: 11400000, guid: 0be87170c871bfc4f91119634daa9c79, type: 2}
m_ManifestExperimental: {fileID: 11400000, guid: 1121701af0c4d7145af70356f0ac2a83,
type: 2}
m_ZapboxManifest: {fileID: 11400000, guid: 7be45b23483e18347a0170a596bf2867, type: 2}
Expand Down
37 changes: 22 additions & 15 deletions Assets/Scripts/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using UnityEngine;
using Newtonsoft.Json;
using TMPro;
using UnityEngine.Serialization;
#if USD_SUPPORTED
using Unity.Formats.USD;
#endif
Expand Down Expand Up @@ -191,11 +192,22 @@ public static void Log(string msg)

[SerializeField] GpuIntersector m_GpuIntersector;

public TiltBrushManifest m_Manifest;

// Previously Experimental-Mode only
[SerializeField] private TiltBrushManifest m_ManifestStandard;
[SerializeField] private TiltBrushManifest m_ManifestExperimental;
[SerializeField] private TiltBrushManifest m_ZapboxManifest;
private TiltBrushManifest m_ManifestFull;

public TiltBrushManifest ManifestFull
{
get
{
if (m_ManifestFull == null)
{
m_ManifestFull = MergeManifests();
}
return m_ManifestFull;
}
}

[SerializeField] private SelectionEffect m_SelectionEffect;

Expand Down Expand Up @@ -552,8 +564,6 @@ void Awake()
gameObject.AddComponent<AutoProfiler>();
}

m_Manifest = GetMergedManifest();

m_HttpServer = GetComponentInChildren<HttpServer>();
if (!Config.IsMobileHardware)
{
Expand Down Expand Up @@ -2201,19 +2211,16 @@ void OnPlaybackComplete()
}
}

public TiltBrushManifest GetMergedManifest(bool forceExperimental = false)
private TiltBrushManifest MergeManifests()
{
var manifest = m_Manifest;
if (Config.IsExperimental || forceExperimental)
#if ZAPBOX_SUPPORTED
var manifest = m_ZapboxManifest;
#else
var manifest = Instantiate(m_ManifestStandard);
if (m_ManifestExperimental != null)
{
if (m_ManifestExperimental != null)
{
manifest = Instantiate(m_Manifest);
manifest.AppendFrom(m_ManifestExperimental);
}
manifest.AppendFrom(m_ManifestExperimental);
}
#if ZAPBOX_SUPPORTED
manifest = m_ZapboxManifest;
#endif
return manifest;
}
Expand Down
15 changes: 9 additions & 6 deletions Assets/Scripts/BrushCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,19 +189,22 @@ public void BeginReload()
m_GuiBrushList.Clear();
foreach (var brush in m_GuidToBrush.Values)
{
if (brush.m_HiddenInGui)
// Some brushes are hardcoded as hidden
if (brush.m_HiddenInGui) continue;
// Always include if experimental mode is on
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this override the zapbox manifest and add them anyways? zapbox is fairly tailored to only show the brushes that work in their passthrough right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure MergeManifests handles this correctly and always returns the correct manifest. Obviously worth checking in a build.

if (Config.IsExperimental || !App.Instance.IsBrushExperimental(brush))
{
continue;
m_GuiBrushList.Add(brush);
}
m_GuiBrushList.Add(brush);
}
BrushCatalogChanged?.Invoke();
}


public Brush[] GetTagFilteredBrushList()
{
List<string> includeTags = App.UserConfig.Brushes.IncludeTags.ToList();
List<string> excludeTags = App.UserConfig.Brushes.ExcludeTags.ToList();
List<string> includeTags = App.UserConfig.Brushes.IncludeTags?.ToList();
List<string> excludeTags = App.UserConfig.Brushes.ExcludeTags?.ToList();

if (includeTags == null || includeTags.Count == 0)
{
Expand Down Expand Up @@ -288,7 +291,7 @@ Brush _FindBrushByDescription(string brushDescription)
static private List<Brush> LoadBrushesInManifest()
{
List<Brush> output = new List<Brush>();
var manifest = App.Instance.m_Manifest;
var manifest = App.Instance.ManifestFull;
foreach (var desc in manifest.Brushes)
{
if (desc != null)
Expand Down
19 changes: 3 additions & 16 deletions Assets/Scripts/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ private class UserConfigChange
// The sdk mode indicates which SDK that we're using to drive the display.
public SdkMode m_SdkMode;

// Stores the value of IsExperimental at startup time
[NonSerialized] public bool m_WasExperimentalAtStartup;

// Whether or not to just do an automatic profile and then exit.
public bool m_AutoProfile;
// How long to wait before starting to profile.
Expand All @@ -126,7 +123,7 @@ private class UserConfigChange
public string[] m_SketchFiles = new string[0];
[NonSerialized] public bool m_QuickLoad = true;

public SecretsConfig.ServiceAuthData GoogleSecrets => Secrets[SecretsConfig.Service.Google];
public SecretsConfig.ServiceAuthData GoogleSecrets => Secrets?[SecretsConfig.Service.Google];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason this line changed and not the rest of the secrets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was specifically throwing an error and the others weren't. Want me to change them all?

public SecretsConfig.ServiceAuthData SketchfabSecrets => Secrets[SecretsConfig.Service.Sketchfab];
public SecretsConfig.ServiceAuthData OculusSecrets => Secrets[SecretsConfig.Service.Oculus];
public SecretsConfig.ServiceAuthData OculusMobileSecrets => Secrets[SecretsConfig.Service.OculusMobile];
Expand Down Expand Up @@ -530,12 +527,6 @@ public bool GeometryShaderSuppported
}
}

// Non-Static version of above
public bool GetIsExperimental()
{
return PlayerPrefs.HasKey("ExperimentalMode") && PlayerPrefs.GetInt("ExperimentalMode") == 1;
}

public void SetIsExperimental(bool active)
{
PlayerPrefs.SetInt("ExperimentalMode", active ? 1 : 0);
Expand All @@ -546,7 +537,6 @@ public void SetIsExperimental(bool active)
void Awake()
{
m_SingletonState = this;
m_WasExperimentalAtStartup = GetIsExperimental();

#if UNITY_EDITOR
if (!string.IsNullOrEmpty(m_FakeCommandLineArgsInEditor))
Expand Down Expand Up @@ -580,12 +570,9 @@ void Awake()
#endif

m_BrushReplacement = new Dictionary<Guid, Guid>();
if (IsExperimental)
foreach (var brush in m_BrushReplacementMap)
{
foreach (var brush in m_BrushReplacementMap)
{
m_BrushReplacement.Add(new Guid(brush.FromGuid), new Guid(brush.ToGuid));
}
m_BrushReplacement.Add(new Guid(brush.FromGuid), new Guid(brush.ToGuid));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/EnvironmentCatalog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void Update()

static void LoadEnvironmentsInManifest(List<Environment> output)
{
var manifest = App.Instance.m_Manifest;
var manifest = App.Instance.ManifestFull;
foreach (var asset in manifest.Environments)
{
if (asset != null)
Expand Down
3 changes: 1 addition & 2 deletions Assets/Scripts/GUI/AppSettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class AppSettingsPanel : BasePanel
public override void InitPanel()
{
base.InitPanel();
m_ExperimentalModeToggle.IsToggledOn = App.Config.GetIsExperimental();
m_ExperimentalModeToggle.IsToggledOn = Config.IsExperimental;
}

public void HandleToggleHandedness()
Expand All @@ -43,7 +43,6 @@ public void HandleResetFirstUse()
public void HandleToggleExperimentalMode(ToggleButton btn)
{
App.Config.SetIsExperimental(btn.IsToggledOn);
RestartNotification();
}

private void RestartNotification()
Expand Down
5 changes: 1 addition & 4 deletions Assets/Scripts/GUI/BrushTypeButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ public void SetButtonProperties(BrushDescriptor rBrush)
VisualizerManager.m_Instance.VisualsRequested);
// Play standard click sound if brush doesn't have a custom button sound
m_ButtonHasPressedAudio = (rBrush.m_ButtonAudio == null);
if (App.Config.m_WasExperimentalAtStartup)
{
m_ExperimentalIcon.SetActive(App.Instance.IsBrushExperimental(rBrush));
}
m_ExperimentalIcon.SetActive(App.Instance.IsBrushExperimental(rBrush));
}

override protected void OnDescriptionActivated()
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/GUI/LocalePopUpWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ override public void Init(GameObject rParent, string sText)
//build list of locale presets we're going to show
Locale currentSelectedLocale = LocalizationSettings.SelectedLocale;

m_Locales = App.Instance.m_Manifest.Locales;
m_Locales = App.Instance.ManifestFull.Locales;

int iPresetIndex = -1;
m_CurrentPresetIdCode = currentSelectedLocale.Identifier.Code;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Rendering/IconTextureAtlas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Material GetAppropriateMaterial(bool activated, bool focus)
void AtlasIconTextures()
{
// Load the appropriate catalog from Resources.
string catalogPath = App.Config.GetIsExperimental() ? m_ExperimentalCatalogPath : m_CatalogPath;
string catalogPath = m_ExperimentalCatalogPath;
m_Catalog = Resources.Load<IconTextureAtlasCatalog>(catalogPath);
Debug.Assert(m_Catalog != null);

Expand Down
48 changes: 19 additions & 29 deletions Assets/Scripts/UserConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,7 @@ public string[] IncludeTags
{
if (m_IncludeTags == null)
{
if (App.Config.GetIsExperimental())
{
m_IncludeTags = new[] { "default", "experimental" };
}
else
{
m_IncludeTags = new[] { "default" };
}
m_IncludeTags = new[] { "default", "experimental" };
}
return m_IncludeTags;
}
Expand Down Expand Up @@ -550,37 +543,34 @@ public Dictionary<Guid, Guid> BrushReplacementMap
get
{
Dictionary<Guid, Guid> results = new Dictionary<Guid, Guid>();
if (Config.IsExperimental)
if (string.IsNullOrEmpty(BrushReplacements))
{
if (string.IsNullOrEmpty(BrushReplacements))
{
return results;
}
var replacements = BrushReplacements.Split(',');
foreach (string replacement in replacements)
return results;
}
var replacements = BrushReplacements.Split(',');
foreach (string replacement in replacements)
{
string[] pair = replacement.Split('=');
if (pair.Length == 2)
{
string[] pair = replacement.Split('=');
if (pair.Length == 2)
if (pair[0] == "*")
{
if (pair[0] == "*")
{
Guid guid = new Guid(pair[1]);
foreach (var brush in App.Instance.m_Manifest.Brushes)
{
results.Add(brush.m_Guid, guid);
}
}
else
Guid guid = new Guid(pair[1]);
foreach (var brush in App.Instance.ManifestFull.Brushes)
{
results.Add(new Guid(pair[0]), new Guid(pair[1]));
results.Add(brush.m_Guid, guid);
}
}
else
{
OutputWindowScript.Error("BrushReplacement should be of the form:\n" +
"brushguidA=brushguidB,brushguidC=brushguidD");
results.Add(new Guid(pair[0]), new Guid(pair[1]));
}
}
else
{
OutputWindowScript.Error("BrushReplacement should be of the form:\n" +
"brushguidA=brushguidB,brushguidC=brushguidD");
}
}
return results;
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Settings/Localization/Strings/Strings_en.asset
Original file line number Diff line number Diff line change
Expand Up @@ -3081,7 +3081,7 @@ MonoBehaviour:
m_Metadata:
m_Items: []
- m_Id: 89093153698373632
m_Localized: (Restart required)
m_Localized: Less compatibility when exported. See our docs.
m_Metadata:
m_Items: []
- m_Id: 89093320602312704
Expand Down
Loading