Skip to content

Commit 38a2c88

Browse files
committed
Runtime switching for experimental brushes
1 parent 36360c6 commit 38a2c88

File tree

12 files changed

+62
-76
lines changed

12 files changed

+62
-76
lines changed

Assets/Editor/BuildTiltBrush.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,7 @@ static void ShowBrushExportTextures()
14351435
using (var unused = new TempHookUpSingletons())
14361436
{
14371437
// Set consultUserConfig = false to keep user config from affecting the build output.
1438-
TiltBrushManifest manifest = App.Instance.GetMergedManifest(forceExperimental: true);
1438+
TiltBrushManifest manifest = App.Instance.ManifestFull;
14391439

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

15521552
// Some sanity checks
15531553
{

Assets/Scenes/Main.unity

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10198,7 +10198,7 @@ MonoBehaviour:
1019810198
m_FadeFromBlackDuration: 3
1019910199
m_QuickLoadHintDelay: 2
1020010200
m_GpuIntersector: {fileID: 165291219}
10201-
m_Manifest: {fileID: 11400000, guid: 0be87170c871bfc4f91119634daa9c79, type: 2}
10201+
m_ManifestStandard: {fileID: 11400000, guid: 0be87170c871bfc4f91119634daa9c79, type: 2}
1020210202
m_ManifestExperimental: {fileID: 11400000, guid: 1121701af0c4d7145af70356f0ac2a83,
1020310203
type: 2}
1020410204
m_ZapboxManifest: {fileID: 11400000, guid: 7be45b23483e18347a0170a596bf2867, type: 2}

Assets/Scripts/App.cs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using UnityEngine;
2424
using Newtonsoft.Json;
2525
using TMPro;
26+
using UnityEngine.Serialization;
2627
#if USD_SUPPORTED
2728
using Unity.Formats.USD;
2829
#endif
@@ -191,11 +192,22 @@ public static void Log(string msg)
191192

192193
[SerializeField] GpuIntersector m_GpuIntersector;
193194

194-
public TiltBrushManifest m_Manifest;
195-
196-
// Previously Experimental-Mode only
195+
[SerializeField] private TiltBrushManifest m_ManifestStandard;
197196
[SerializeField] private TiltBrushManifest m_ManifestExperimental;
198197
[SerializeField] private TiltBrushManifest m_ZapboxManifest;
198+
private TiltBrushManifest m_ManifestFull;
199+
200+
public TiltBrushManifest ManifestFull
201+
{
202+
get
203+
{
204+
if (m_ManifestFull == null)
205+
{
206+
m_ManifestFull = MergeManifests();
207+
}
208+
return m_ManifestFull;
209+
}
210+
}
199211

200212
[SerializeField] private SelectionEffect m_SelectionEffect;
201213

@@ -552,8 +564,6 @@ void Awake()
552564
gameObject.AddComponent<AutoProfiler>();
553565
}
554566

555-
m_Manifest = GetMergedManifest();
556-
557567
m_HttpServer = GetComponentInChildren<HttpServer>();
558568
if (!Config.IsMobileHardware)
559569
{
@@ -2201,19 +2211,16 @@ void OnPlaybackComplete()
22012211
}
22022212
}
22032213

2204-
public TiltBrushManifest GetMergedManifest(bool forceExperimental = false)
2214+
private TiltBrushManifest MergeManifests()
22052215
{
2206-
var manifest = m_Manifest;
2207-
if (Config.IsExperimental || forceExperimental)
2216+
#if ZAPBOX_SUPPORTED
2217+
var manifest = m_ZapboxManifest;
2218+
#else
2219+
var manifest = Instantiate(m_ManifestStandard);
2220+
if (m_ManifestExperimental != null)
22082221
{
2209-
if (m_ManifestExperimental != null)
2210-
{
2211-
manifest = Instantiate(m_Manifest);
2212-
manifest.AppendFrom(m_ManifestExperimental);
2213-
}
2222+
manifest.AppendFrom(m_ManifestExperimental);
22142223
}
2215-
#if ZAPBOX_SUPPORTED
2216-
manifest = m_ZapboxManifest;
22172224
#endif
22182225
return manifest;
22192226
}

Assets/Scripts/BrushCatalog.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,22 @@ public void BeginReload()
189189
m_GuiBrushList.Clear();
190190
foreach (var brush in m_GuidToBrush.Values)
191191
{
192-
if (brush.m_HiddenInGui)
192+
// Some brushes are hardcoded as hidden
193+
if (brush.m_HiddenInGui) continue;
194+
// Always include if experimental mode is on
195+
if (Config.IsExperimental || !App.Instance.IsBrushExperimental(brush))
193196
{
194-
continue;
197+
m_GuiBrushList.Add(brush);
195198
}
196-
m_GuiBrushList.Add(brush);
197199
}
200+
BrushCatalogChanged?.Invoke();
198201
}
199202

200203

201204
public Brush[] GetTagFilteredBrushList()
202205
{
203-
List<string> includeTags = App.UserConfig.Brushes.IncludeTags.ToList();
204-
List<string> excludeTags = App.UserConfig.Brushes.ExcludeTags.ToList();
206+
List<string> includeTags = App.UserConfig.Brushes.IncludeTags?.ToList();
207+
List<string> excludeTags = App.UserConfig.Brushes.ExcludeTags?.ToList();
205208

206209
if (includeTags == null || includeTags.Count == 0)
207210
{
@@ -288,7 +291,7 @@ Brush _FindBrushByDescription(string brushDescription)
288291
static private List<Brush> LoadBrushesInManifest()
289292
{
290293
List<Brush> output = new List<Brush>();
291-
var manifest = App.Instance.m_Manifest;
294+
var manifest = App.Instance.ManifestFull;
292295
foreach (var desc in manifest.Brushes)
293296
{
294297
if (desc != null)

Assets/Scripts/Config.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ private class UserConfigChange
113113
// The sdk mode indicates which SDK that we're using to drive the display.
114114
public SdkMode m_SdkMode;
115115

116-
// Stores the value of IsExperimental at startup time
117-
[NonSerialized] public bool m_WasExperimentalAtStartup;
118-
119116
// Whether or not to just do an automatic profile and then exit.
120117
public bool m_AutoProfile;
121118
// How long to wait before starting to profile.
@@ -126,7 +123,7 @@ private class UserConfigChange
126123
public string[] m_SketchFiles = new string[0];
127124
[NonSerialized] public bool m_QuickLoad = true;
128125

129-
public SecretsConfig.ServiceAuthData GoogleSecrets => Secrets[SecretsConfig.Service.Google];
126+
public SecretsConfig.ServiceAuthData GoogleSecrets => Secrets?[SecretsConfig.Service.Google];
130127
public SecretsConfig.ServiceAuthData SketchfabSecrets => Secrets[SecretsConfig.Service.Sketchfab];
131128
public SecretsConfig.ServiceAuthData OculusSecrets => Secrets[SecretsConfig.Service.Oculus];
132129
public SecretsConfig.ServiceAuthData OculusMobileSecrets => Secrets[SecretsConfig.Service.OculusMobile];
@@ -530,12 +527,6 @@ public bool GeometryShaderSuppported
530527
}
531528
}
532529

533-
// Non-Static version of above
534-
public bool GetIsExperimental()
535-
{
536-
return PlayerPrefs.HasKey("ExperimentalMode") && PlayerPrefs.GetInt("ExperimentalMode") == 1;
537-
}
538-
539530
public void SetIsExperimental(bool active)
540531
{
541532
PlayerPrefs.SetInt("ExperimentalMode", active ? 1 : 0);
@@ -546,7 +537,6 @@ public void SetIsExperimental(bool active)
546537
void Awake()
547538
{
548539
m_SingletonState = this;
549-
m_WasExperimentalAtStartup = GetIsExperimental();
550540

551541
#if UNITY_EDITOR
552542
if (!string.IsNullOrEmpty(m_FakeCommandLineArgsInEditor))
@@ -580,12 +570,9 @@ void Awake()
580570
#endif
581571

582572
m_BrushReplacement = new Dictionary<Guid, Guid>();
583-
if (IsExperimental)
573+
foreach (var brush in m_BrushReplacementMap)
584574
{
585-
foreach (var brush in m_BrushReplacementMap)
586-
{
587-
m_BrushReplacement.Add(new Guid(brush.FromGuid), new Guid(brush.ToGuid));
588-
}
575+
m_BrushReplacement.Add(new Guid(brush.FromGuid), new Guid(brush.ToGuid));
589576
}
590577
}
591578

Assets/Scripts/EnvironmentCatalog.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void Update()
107107

108108
static void LoadEnvironmentsInManifest(List<Environment> output)
109109
{
110-
var manifest = App.Instance.m_Manifest;
110+
var manifest = App.Instance.ManifestFull;
111111
foreach (var asset in manifest.Environments)
112112
{
113113
if (asset != null)

Assets/Scripts/GUI/AppSettingsPanel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class AppSettingsPanel : BasePanel
2424
public override void InitPanel()
2525
{
2626
base.InitPanel();
27-
m_ExperimentalModeToggle.IsToggledOn = App.Config.GetIsExperimental();
27+
m_ExperimentalModeToggle.IsToggledOn = Config.IsExperimental;
2828
}
2929

3030
public void HandleToggleHandedness()
@@ -43,7 +43,6 @@ public void HandleResetFirstUse()
4343
public void HandleToggleExperimentalMode(ToggleButton btn)
4444
{
4545
App.Config.SetIsExperimental(btn.IsToggledOn);
46-
RestartNotification();
4746
}
4847

4948
private void RestartNotification()

Assets/Scripts/GUI/BrushTypeButton.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void SetButtonProperties(BrushDescriptor rBrush)
114114
VisualizerManager.m_Instance.VisualsRequested);
115115
// Play standard click sound if brush doesn't have a custom button sound
116116
m_ButtonHasPressedAudio = (rBrush.m_ButtonAudio == null);
117-
if (App.Config.m_WasExperimentalAtStartup)
117+
if (Config.IsExperimental)
118118
{
119119
m_ExperimentalIcon.SetActive(App.Instance.IsBrushExperimental(rBrush));
120120
}

Assets/Scripts/GUI/LocalePopUpWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ override public void Init(GameObject rParent, string sText)
4747
//build list of locale presets we're going to show
4848
Locale currentSelectedLocale = LocalizationSettings.SelectedLocale;
4949

50-
m_Locales = App.Instance.m_Manifest.Locales;
50+
m_Locales = App.Instance.ManifestFull.Locales;
5151

5252
int iPresetIndex = -1;
5353
m_CurrentPresetIdCode = currentSelectedLocale.Identifier.Code;

Assets/Scripts/Rendering/IconTextureAtlas.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public Material GetAppropriateMaterial(bool activated, bool focus)
5656
void AtlasIconTextures()
5757
{
5858
// Load the appropriate catalog from Resources.
59-
string catalogPath = App.Config.GetIsExperimental() ? m_ExperimentalCatalogPath : m_CatalogPath;
59+
string catalogPath = m_ExperimentalCatalogPath;
6060
m_Catalog = Resources.Load<IconTextureAtlasCatalog>(catalogPath);
6161
Debug.Assert(m_Catalog != null);
6262

0 commit comments

Comments
 (0)