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

User overrides for platform settings #643

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
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
68 changes: 68 additions & 0 deletions Assets/Editor/ExportQualitySettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Text;

public class ExportQualitySettings
{
[MenuItem("Open Brush/Export Quality Settings to CSV")]
private static void ExportQualitySettingsToCSV()
{
StringBuilder csvContent = new StringBuilder();
string filePath = Path.Combine(Application.dataPath, "QualitySettings.csv");

// Add CSV headers
csvContent.AppendLine("Name,pixelLightCount,antiAliasing,realtimeReflectionProbes,resolutionScalingFixedDPIFactor,vSyncCount,anisotropicFiltering,masterTextureLimit,streamingMipmapsActive,streamingMipmapsMemoryBudget,streamingMipmapsRenderersPerFrame,streamingMipmapsMaxLevelReduction,streamingMipmapsMaxFileIORequests,streamingMipmapsAddAllCameras,softParticles,particleRaycastBudget,billboardsFaceCameraPosition,shadowmaskMode,shadows,shadowResolution,shadowProjection,shadowDistance,shadowNearPlaneOffset,shadowCascades,skinWeights,asyncUploadTimeSlice,asyncUploadBufferSize,asyncUploadPersistentBuffer,lodBias,maximumLODLevel,skinWeights");

for (int i = 0; i < QualitySettings.names.Length; i++)
{
QualitySettings.SetQualityLevel(i, applyExpensiveChanges: true);
string line = string.Format("\"{0}\",{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16},{17},{18},{19},{20},{21},{22},{23},{24},{25},{26},{27},{28},{29},{30}",
QualitySettings.names[i],
QualitySettings.pixelLightCount,
QualitySettings.antiAliasing,
QualitySettings.realtimeReflectionProbes,
QualitySettings.resolutionScalingFixedDPIFactor,
QualitySettings.vSyncCount,

QualitySettings.anisotropicFiltering,
QualitySettings.masterTextureLimit,
QualitySettings.streamingMipmapsActive,
QualitySettings.streamingMipmapsMemoryBudget,
QualitySettings.streamingMipmapsRenderersPerFrame,
QualitySettings.streamingMipmapsMaxLevelReduction,
QualitySettings.streamingMipmapsMaxFileIORequests,
QualitySettings.streamingMipmapsAddAllCameras,

QualitySettings.softParticles,
QualitySettings.particleRaycastBudget,

QualitySettings.billboardsFaceCameraPosition,

QualitySettings.shadowmaskMode,
QualitySettings.shadows,
QualitySettings.shadowResolution,
QualitySettings.shadowProjection,
QualitySettings.shadowDistance,
QualitySettings.shadowNearPlaneOffset,
QualitySettings.shadowCascades,

QualitySettings.skinWeights,

QualitySettings.asyncUploadTimeSlice,
QualitySettings.asyncUploadBufferSize,
QualitySettings.asyncUploadPersistentBuffer,

QualitySettings.lodBias,
QualitySettings.maximumLODLevel,

QualitySettings.skinWeights
);

csvContent.AppendLine(line);
}

File.WriteAllText(filePath, csvContent.ToString());
Debug.Log("Quality settings dumped to " + filePath);
}
}
3 changes: 3 additions & 0 deletions Assets/Editor/ExportQualitySettings.cs.meta

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

25 changes: 25 additions & 0 deletions Assets/Editor/WriteFullUserConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Newtonsoft.Json;
using UnityEditor;
using UnityEngine;
using System.IO;

namespace TiltBrush
{
public class WriteFullUserConfig
{
[MenuItem("Open Brush/Write Full User Config")]
public static void DoWriteFullUserConfig()
{
// Quit if we're not in play mode
if (!Application.isPlaying)
{
Debug.LogError("Enter Play Mode and try again.");
return;
}
string path = $"{App.UserPath()}/Full Open Brush.cfg";
string json = JsonConvert.SerializeObject(App.UserConfig, Formatting.Indented);
File.WriteAllText(path, json);
Debug.Log($"User data written to {path}");
}
}
}
3 changes: 3 additions & 0 deletions Assets/Editor/WriteFullUserConfig.cs.meta

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

4 changes: 2 additions & 2 deletions Assets/QualityLevels Mobile.asset
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ MonoBehaviour:
m_MaxSimplificationUserStrokes: 2
m_GpuLevel: 3
m_FixedFoveationLevel: 0
- m_Bloom: 0
- m_Bloom: 3
m_Hdr: 0
m_Fxaa: 0
m_MsaaLevel: 2
Expand All @@ -103,7 +103,7 @@ MonoBehaviour:
m_MaxSimplificationUserStrokes: 2
m_GpuLevel: 5
m_FixedFoveationLevel: 0
- m_Bloom: 0
- m_Bloom: 3
m_Hdr: 0
m_Fxaa: 0
m_MsaaLevel: 2
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Brushes/HullBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ public HullBrush()
override public bool ShouldCurrentLineEnd()
{
// Reminder: it's ok for this method to be nondeterministic.
int localMaxKnotCount = App.PlatformConfig.HullBrushMaxKnots;
int maxVertInputCount = App.PlatformConfig.HullBrushMaxVertInputs;
int localMaxKnotCount = UserConfig.PerformanceOverrides.HullBrushMaxKnots;
int maxVertInputCount = UserConfig.PerformanceOverrides.HullBrushMaxVertInputs;
int hullInputSize = m_AllVertices.Count(v => !v.DefinitelyInterior);

// For Hull Brush, the limiting factor is the number of points we send to the hull
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Export/ExportCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static ExportUtils.GroupPayload BuildGroupPayload(SceneStatePayload payload,
ExportUtils.ReverseTriangleWinding(geometry, 1, 2);
}

if (App.PlatformConfig.EnableExportMemoryOptimization &&
if (UserConfig.PerformanceOverrides.EnableExportMemoryOptimization &&
payload.temporaryDirectory != null)
{
string filename = Path.Combine(
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/FileWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class FileWatcher

public FileWatcher(string path)
{
if (App.PlatformConfig.UseFileSystemWatcher)
if (UserConfig.PerformanceOverrides.UseFileSystemWatcher)
{
m_InternalFileWatcher = new FileSystemWatcher(path);
AddEventsToInternalFileWatcher();
Expand All @@ -36,7 +36,7 @@ public FileWatcher(string path)

public FileWatcher(string path, string filter)
{
if (App.PlatformConfig.UseFileSystemWatcher)
if (UserConfig.PerformanceOverrides.UseFileSystemWatcher)
{
m_InternalFileWatcher = new FileSystemWatcher(path, filter);
AddEventsToInternalFileWatcher();
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/GUI/ReferencePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ override protected void OnEnablePanel()
default:
// If we have no filewatcher, we need to check if any files have changed since the user
// last had the panel open.
if (!App.PlatformConfig.UseFileSystemWatcher)
if (!UserConfig.PerformanceOverrides.UseFileSystemWatcher)
{
m_CurrentTab.Catalog.ForceCatalogScan();
RefreshPage();
Expand Down
18 changes: 4 additions & 14 deletions Assets/Scripts/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -756,31 +756,21 @@ public bool ControllersAreSwapping()

public Vector2 GetMouseMoveDelta()
{
if (App.Config.IsMobileHardware)
{
return Vector2.zero;
}

Vector2 mv = Mouse.current.delta.ReadValue() * 0.125f;
return new Vector2(Mathf.Abs(mv.x) > m_InputThreshold ? mv.x : 0f,
Mathf.Abs(mv.y) > m_InputThreshold ? mv.y : 0f);
}

public float GetMouseWheel()
{
if (App.Config.IsMobileHardware)
{
return 0.0f;
}

return Mouse.current.scroll.x.ReadValue();
return Mouse.current != null ? Mouse.current.scroll.x.ReadValue() : 0f;
}

/// Mouse input is ignored on mobile platform because the Oculus Quest seems to emulate mouse
/// presses when you fiddle with the joystick.
public bool GetMouseButton(int button)
{
if (App.Config.IsMobileHardware)
if (Mouse.current == null)
{
return false;
}
Expand All @@ -800,7 +790,7 @@ public bool GetMouseButton(int button)
/// presses when you fiddle with the joystick.
public bool GetMouseButtonDown(int button)
{
if (App.Config.IsMobileHardware)
if (Mouse.current == null)
{
return false;
}
Expand All @@ -824,7 +814,7 @@ public bool IsBrushScrollActive()
public float GetBrushScrollAmount()
{
// Check mouse first.
if (!App.Config.IsMobileHardware)
if (Mouse.current != null)
{
float fMouse = Mouse.current.delta.x.ReadValue();
if (Mathf.Abs(fMouse) > m_InputThreshold)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/MultiCamCaptureRig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void UpdateObjectCameraTransform(MultiCamStyle style, Transform xf, float

// For the mobile version we need to adjust the camera fov so that the frustum exactly matches
// the view through the viewfinder. The camera is placed at the vr camera position.
if (!App.PlatformConfig.EnableMulticamPreview)
if (!UserConfig.PerformanceOverrides.EnableMulticamPreview)
{
obj.m_Camera.transform.position = App.VrSdk.GetVrCamera().transform.position;
obj.m_Camera.transform.rotation = xf.rotation;
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/PlatformConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,7 @@ public class PlatformConfig : ScriptableObject
// A mapping between the framerate and the frame gap between multicam previews.
// (Leave empty to not have any gaps)
public AnimationCurve FrameRateToPreviewRenderGap;

}

} // namespace TiltBrush
2 changes: 1 addition & 1 deletion Assets/Scripts/Playback/ScenePlaybackByDistance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public bool Update()
// Unity appears to only clean up memory from mucking about with meshes on frame boundaries,
// So Tilt Brush was using vast amounts of memory to do a quickload.
// This causes Tilt Brush to only draw a certain distance before returning a frame.
float maxDistancePerFrame = App.PlatformConfig.QuickLoadMaxDistancePerFrame;
float maxDistancePerFrame = UserConfig.PerformanceOverrides.QuickLoadMaxDistancePerFrame;
if (m_metersRemaining > maxDistancePerFrame)
{
m_metersRemaining = maxDistancePerFrame;
Expand Down
12 changes: 6 additions & 6 deletions Assets/Scripts/ReferenceImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ IEnumerable LoadImage(string path, Texture2D dest, bool runForeground = false)
// ReturnImageFullSize is called during load.
m_FullSizeReferences++;
var reader = new ThreadedImageReader(path, -1,
App.PlatformConfig.ReferenceImagesMaxDimension);
UserConfig.PerformanceOverrides.ReferenceImagesMaxDimension);
while (!reader.Finished)
{
if (!runForeground) { yield return null; }
Expand All @@ -214,7 +214,7 @@ IEnumerable LoadImage(string path, Texture2D dest, bool runForeground = false)
result = reader.Result;
if (result != null && dest != null)
{
int resizeLimit = App.PlatformConfig.ReferenceImagesResizeDimension;
int resizeLimit = UserConfig.PerformanceOverrides.ReferenceImagesResizeDimension;
if (result.ColorWidth > resizeLimit || result.ColorHeight > resizeLimit)
{
// Resize the image to the resize limit before saving it to the dest texture.
Expand Down Expand Up @@ -354,7 +354,7 @@ public bool RequestLoad(bool allowMainThread = false)

ImageCache.SaveImageCache(tex, FilePath);
m_ImageAspect = (float)tex.width / tex.height;
int resizeLimit = App.PlatformConfig.ReferenceImagesResizeDimension;
int resizeLimit = UserConfig.PerformanceOverrides.ReferenceImagesResizeDimension;
if (tex.width > resizeLimit || tex.height > resizeLimit)
{
Texture2D resizedTex = new Texture2D(2, 2, TextureFormat.RGBA32, true);
Expand Down Expand Up @@ -388,7 +388,7 @@ public bool RequestLoad(bool allowMainThread = false)

ImageCache.SaveImageCache(tex, FilePath);
m_ImageAspect = (float)tex.width / tex.height;
int resizeLimit = App.PlatformConfig.ReferenceImagesResizeDimension;
int resizeLimit = UserConfig.PerformanceOverrides.ReferenceImagesResizeDimension;
if (tex.width > resizeLimit || tex.height > resizeLimit)
{
Texture2D resizedTex = new Texture2D(2, 2, TextureFormat.RGBA32, true);
Expand Down Expand Up @@ -526,7 +526,7 @@ IEnumerator<Timeslice> RequestLoadCoroutineMainThread()
yield return null;

// Create the full size image cache as well.
int resizeLimit = App.PlatformConfig.ReferenceImagesResizeDimension;
int resizeLimit = UserConfig.PerformanceOverrides.ReferenceImagesResizeDimension;
if (inTex.width > resizeLimit || inTex.height > resizeLimit)
{
Texture2D resizedTex = new Texture2D(2, 2, TextureFormat.RGBA32, true);
Expand Down Expand Up @@ -555,7 +555,7 @@ IEnumerable<Timeslice> RequestLoadCoroutine()
{
var reader = new ThreadedImageReader(m_Path,
ReferenceImageCatalog.MAX_ICON_TEX_DIMENSION,
App.PlatformConfig.ReferenceImagesMaxDimension);
UserConfig.PerformanceOverrides.ReferenceImagesMaxDimension);
while (!reader.Finished)
{
yield return null;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/ReferencePanelTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public virtual void UpdateTab() { }

public virtual void OnTabEnable()
{
if (!App.PlatformConfig.UseFileSystemWatcher)
if (!UserConfig.PerformanceOverrides.UseFileSystemWatcher)
{
Catalog.ForceCatalogScan();
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Save/SaveLoadScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public bool AutosaveEnabled
get
{
return !m_AutosaveFailed &&
App.PlatformConfig.EnableAutosave &&
UserConfig.PerformanceOverrides.EnableAutosave &&
!App.UserConfig.Flags.DisableAutosave;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/ScreenshotManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void Start()
SceneSettings.m_Instance.RegisterCamera(m_RightInfo.camera);
}

if (!App.Config.PlatformConfig.EnableMulticamPreview)
if (!UserConfig.PerformanceOverrides.EnableMulticamPreview)
{
// If we're looking through the viewfinder, we need to make some changes to this camera
SetScreenshotResolution(App.UserConfig.Flags.SnapshotWidth > 0
Expand Down
54 changes: 24 additions & 30 deletions Assets/Scripts/Sharing/DriveSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,17 +463,14 @@ private async Task SetupSyncFoldersAsync(CancellationToken token)
SyncType.Upload,
SyncedFolderType.MediaLibrary,
token));
if (!App.Config.IsMobileHardware)
{
folderSyncs.Add(AddSyncedFolderAsync(
"Models",
App.ModelLibraryPath(),
mediaLibrary.Id,
SyncType.Upload,
SyncedFolderType.MediaLibrary,
token,
recursive: true));
}
folderSyncs.Add(AddSyncedFolderAsync(
"Models",
App.ModelLibraryPath(),
mediaLibrary.Id,
SyncType.Upload,
SyncedFolderType.MediaLibrary,
token,
recursive: true));
folderSyncs.Add(AddSyncedFolderAsync(
"Videos",
App.VideoLibraryPath(),
Expand All @@ -493,26 +490,23 @@ private async Task SetupSyncFoldersAsync(CancellationToken token)
token));
}

if (!App.Config.IsMobileHardware)
if (IsFolderOfTypeSynced(SyncedFolderType.Videos))
{
if (IsFolderOfTypeSynced(SyncedFolderType.Videos))
{
folderSyncs.Add(AddSyncedFolderAsync(
"Videos",
App.VideosPath(),
deviceRootId,
SyncType.Upload,
SyncedFolderType.Videos,
token,
excludeExtensions: new[] { ".bat", ".usda" }));
folderSyncs.Add(AddSyncedFolderAsync(
"VrVideos",
App.VrVideosPath(),
deviceRootId,
SyncType.Upload,
SyncedFolderType.Videos,
token));
}
folderSyncs.Add(AddSyncedFolderAsync(
"Videos",
App.VideosPath(),
deviceRootId,
SyncType.Upload,
SyncedFolderType.Videos,
token,
excludeExtensions: new[] { ".bat", ".usda" }));
folderSyncs.Add(AddSyncedFolderAsync(
"VrVideos",
App.VrVideosPath(),
deviceRootId,
SyncType.Upload,
SyncedFolderType.Videos,
token));
}

if (IsFolderOfTypeSynced(SyncedFolderType.Exports))
Expand Down
Loading