Adding support for custom background images

This change adds support for custom background images.

Usage:
- Background images are stored in "backgrounds" folder as with jpg or png.
- Both 360 degree (equirectangular) and 6-side cubemap images are supported. This is automatically detected based on aspect ratio (with cubemap having 4:3 aspect ratio).
- Select the background from Settings.

Changes:
- The selected background image is persisted in config in this format: "background": "backgrounds/my_background.jpg",
- Image is decoded in a background thread (via Android plugin), as Texture2D.LoadImage can cause multi-second freeze on the UI thread. We then compensate for unity (re-ordering coordinate origin and also alpha channel).
- Made ground smaller & semi-transparent
This commit is contained in:
tverona1
2019-09-14 18:07:34 -07:00
parent 30fbb2afb6
commit 4f0399bcdf
22 changed files with 3016 additions and 148 deletions
+27
View File
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
@@ -21,7 +22,9 @@ namespace QuestAppLauncher
public GameObject gridPopulation;
public GameObject show2DToggle;
public GameObject autoUpdateToggle;
public GameObject skyBoxButton;
public DownloadStatusIndicator downloadStatusIndicator;
public SkyboxHandler skyboxHandler;
public Toggle tabsAutoOff;
public Toggle tabsAutoTop;
@@ -57,6 +60,9 @@ namespace QuestAppLauncher
// Load config
this.config = ConfigPersistence.LoadConfig();
// Skybox callback
this.skyboxHandler.OnSkyboxSelected = OnSkyboxSelected;
// Set current cols & rows
var colsSlider = this.gridCols.GetComponent<Slider>();
colsSlider.value = this.config.gridSize.cols;
@@ -75,6 +81,9 @@ namespace QuestAppLauncher
// Set 2D toggle
this.show2DToggle.GetComponent<Toggle>().SetIsOnWithoutNotify(this.config.show2D);
// Set skybox button text
this.skyBoxButton.GetComponentInChildren<TextMeshProUGUI>().text = SkyboxHandler.GetSkyboxNameFromPath(this.config.background);
// Set auto-update toggle
this.autoUpdateToggle.GetComponent<Toggle>().SetIsOnWithoutNotify(this.config.autoUpdate);
@@ -142,6 +151,19 @@ namespace QuestAppLauncher
}
}
public void OnSkyboxSelected(string skyboxPath)
{
// Update text
this.skyBoxButton.GetComponentInChildren<TextMeshProUGUI>().text = SkyboxHandler.GetSkyboxNameFromPath(skyboxPath);
// Save config with new skybox selection
if (!this.config.background.Equals(skyboxPath, StringComparison.OrdinalIgnoreCase))
{
this.config.background = skyboxPath;
ConfigPersistence.SaveConfig(this.config);
}
}
public void DeleteRenameFiles()
{
Debug.Log("Delete Rename files");
@@ -166,6 +188,11 @@ namespace QuestAppLauncher
rowsText.text = string.Format("{0} Rows", rows);
}
public void ShowSkyboxList()
{
this.skyboxHandler.ShowList();
}
private bool HasUsageStatsPermissions()
{
// Check if we have UsageStats permission