- Added preliminary support for tabs: Added config support for "categoryType" specifying "none" or "auto". None means no tabs. Auto means that we create 3 tabs - Quest, Go/GearVR and 2D. These apps types are distinguished based on package information.
- Added support in UI for showing / hiding 2D apps.
- Fixed an issue with scroll view collider: Looks like Unity UI scroll view object does not interact very well in a VR environment. This one was a doozy. I noticed, although the scroll view masks UI that falls outside its rectangle (as it should), it does not suppress colliders. This means that it's possible to interact with colliders that get scrolled above the scroll view (i.e. like clicking on a cell to launch an app when that cell is outside the scroll view). The bigger problem is that this interfered with the tabs, which are above the scroll view. After contemplating several solutions, I ended up with a simple but effective one:
// To fix this issue, we cast a ray from current pointer to the scroll view's box collider.
// If we get a hit, it means we're inside the scroll view - so we enable all the children box
// colliders, which will behave as expected.
// If we do not get a hit, it means that we're outside the scroll view - so we disable all the children
// box colliders, which addresses the issue above.
125 lines
4.1 KiB
C#
125 lines
4.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.SceneManagement;
|
|
using TMPro;
|
|
|
|
namespace QuestAppLauncher
|
|
{
|
|
public class SettingsHandler : MonoBehaviour
|
|
{
|
|
public GameObject gridContainer;
|
|
public GameObject openSettingsButton;
|
|
public GameObject closeSettingsButton;
|
|
public GameObject settingsContainer;
|
|
public GameObject gridCols;
|
|
public GameObject gridColsText;
|
|
public GameObject gridRows;
|
|
public GameObject gridRowsText;
|
|
public GameObject gridPopulation;
|
|
public GameObject show2DToggle;
|
|
|
|
private Config config = new Config();
|
|
|
|
public void OpenSettings()
|
|
{
|
|
Debug.Log("Open Settings");
|
|
this.gridContainer.SetActive(false);
|
|
this.openSettingsButton.SetActive(false);
|
|
this.closeSettingsButton.SetActive(true);
|
|
this.settingsContainer.SetActive(true);
|
|
|
|
// Load config
|
|
ConfigPersistence.LoadConfig(this.config);
|
|
|
|
// Set current cols & rows
|
|
var colsSlider = this.gridCols.GetComponent<Slider>();
|
|
colsSlider.value = this.config.gridSize.cols;
|
|
var colsText = this.gridColsText.GetComponent<TextMeshProUGUI>();
|
|
colsText.text = string.Format("{0} Cols", this.config.gridSize.cols);
|
|
|
|
var rowsSlider = this.gridRows.GetComponent<Slider>();
|
|
rowsSlider.value = this.config.gridSize.rows;
|
|
|
|
var rowsText = this.gridRowsText.GetComponent<TextMeshProUGUI>();
|
|
rowsText.text = string.Format("{0} Rows", this.config.gridSize.rows);
|
|
|
|
// Set 2D toggle
|
|
this.show2DToggle.GetComponent<Toggle>().SetIsOnWithoutNotify(this.config.show2D);
|
|
}
|
|
|
|
public void CloseSettings()
|
|
{
|
|
// Persist any config changes
|
|
PersistConfig();
|
|
|
|
Debug.Log("Close Settings");
|
|
this.gridContainer.SetActive(true);
|
|
this.openSettingsButton.SetActive(true);
|
|
this.closeSettingsButton.SetActive(false);
|
|
this.settingsContainer.SetActive(false);
|
|
}
|
|
|
|
public void DeleteExcludedApksFile()
|
|
{
|
|
Debug.Log("Delete Excluded Apk List");
|
|
QuestAppLauncher.GridPopulation.DeleteExcludedApksFile();
|
|
}
|
|
|
|
public void UpdateGridColText()
|
|
{
|
|
var cols = gridCols.GetComponent<Slider>().value;
|
|
var colsText = this.gridColsText.GetComponent<TextMeshProUGUI>();
|
|
colsText.text = string.Format("{0} Cols", cols);
|
|
}
|
|
|
|
public void UpdateGridRowText()
|
|
{
|
|
var rows = gridRows.GetComponent<Slider>().value;
|
|
var rowsText = this.gridRowsText.GetComponent<TextMeshProUGUI>();
|
|
rowsText.text = string.Format("{0} Rows", rows);
|
|
}
|
|
|
|
private void PersistConfig()
|
|
{
|
|
bool saveConfig = false;
|
|
bool rePopulate = false;
|
|
|
|
// Update grid size
|
|
var cols = (int)gridCols.GetComponent<Slider>().value;
|
|
var rows = (int)gridRows.GetComponent<Slider>().value;
|
|
|
|
if (cols != this.config.gridSize.cols ||
|
|
rows != this.config.gridSize.rows)
|
|
{
|
|
this.config.gridSize.cols = cols;
|
|
this.config.gridSize.rows = rows;
|
|
rePopulate = true;
|
|
saveConfig = true;
|
|
}
|
|
|
|
// Update 2D toggle
|
|
var show2D = this.show2DToggle.GetComponent<Toggle>().isOn;
|
|
if (show2D != this.config.show2D)
|
|
{
|
|
this.config.show2D = show2D;
|
|
saveConfig = true;
|
|
rePopulate = true;
|
|
}
|
|
|
|
if (saveConfig)
|
|
{
|
|
// Persist configuration
|
|
ConfigPersistence.SaveConfig(this.config);
|
|
}
|
|
|
|
if (rePopulate)
|
|
{
|
|
// Re-populate grid
|
|
Debug.Log("Re-populating panel");
|
|
this.gridPopulation.GetComponent<GridPopulation>().StartPopulate();
|
|
}
|
|
}
|
|
}
|
|
} |