Merge pull request #8 from tverona1/tabs

Fix controllers that broke with update 7; added UI support for adjusting grid size
This commit is contained in:
tverona1
2019-07-24 22:24:12 -07:00
committed by GitHub
8 changed files with 4312 additions and 740 deletions
@@ -36,6 +36,8 @@ namespace ControllerSelection {
public float rayDrawDistance = 500;
[Tooltip("How far away the gaze pointer should be from the camera.")]
public float gazeDrawDistance = 3;
[Tooltip("Show gaze pointer as ray pointer.")]
public bool showRayPointer = true;
[HideInInspector]
public OVRInput.Controller activeController = OVRInput.Controller.None;
@@ -63,13 +65,20 @@ namespace ControllerSelection {
}
public void SetPointer(Ray ray) {
float hitRayDrawDistance = rayDrawDistance;
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
hitRayDrawDistance = hit.distance;
}
if (linePointer != null) {
linePointer.SetPosition(0, ray.origin);
linePointer.SetPosition(1, ray.origin + ray.direction * rayDrawDistance);
linePointer.SetPosition(1, ray.origin + ray.direction * hitRayDrawDistance);
}
if (gazePointer != null) {
gazePointer.position = ray.origin + ray.direction * gazeDrawDistance;
gazePointer.position = ray.origin + ray.direction * (showRayPointer ? hitRayDrawDistance : gazeDrawDistance);
}
}
@@ -79,7 +88,7 @@ namespace ControllerSelection {
linePointer.enabled = true;
}
if (gazePointer != null) {
gazePointer.gameObject.SetActive(false);
gazePointer.gameObject.SetActive(showRayPointer ? true : false);
}
}
else {
@@ -87,7 +96,7 @@ namespace ControllerSelection {
linePointer.enabled = false;
}
if (gazePointer != null) {
gazePointer.gameObject.SetActive(true);
gazePointer.gameObject.SetActive(showRayPointer ? false : true);
}
}
}
+1 -6
View File
@@ -8,12 +8,7 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!--<intent-filter>
<data android:scheme="questapplauncher" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>-->
</activity>
</application>
<uses-feature android:name="android.hardware.vr.headtracking" android:required="true" android:version="1" />
</manifest>
+1 -1
View File
@@ -292,7 +292,7 @@ BoxCollider:
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 834, y: 547, z: 1}
m_Size: {x: 834, y: 547, z: 0.05}
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &-3040706184271075254
MonoBehaviour:
File diff suppressed because it is too large Load Diff
+7 -3
View File
@@ -18,11 +18,11 @@ namespace QuestAppLauncher
[Serializable]
public class GridSize
{
public int rows;
public int cols;
public int rows = 3;
public int cols = 3;
}
public GridSize gridSize;
public GridSize gridSize = new GridSize();
}
/// <summary>
@@ -54,6 +54,10 @@ namespace QuestAppLauncher
Debug.Log(string.Format("Failed to read config: {0}", e.Message));
}
}
else
{
Debug.Log("Did not find config file: " + configFilePath);
}
}
/// <summary>
+29 -32
View File
@@ -25,8 +25,8 @@ namespace QuestAppLauncher
// Extension search for icon overrides
const string IconOverrideExtSearch = "*.jpg";
// Canvas game object
public GameObject canvas;
// Grid container game object
public GameObject gridContainer;
// Scroll view game object
public GameObject scrollView;
@@ -37,9 +37,6 @@ namespace QuestAppLauncher
// App info GameObject (a cell in the grid content)
public GameObject prefab;
// Configuration
private Config config = new Config();
#region MonoBehaviour handler
void Start()
@@ -50,7 +47,7 @@ namespace QuestAppLauncher
// Initialize the core platform
Core.AsyncInitialize();
// Load configuration
// Process configuration
StartCoroutine(ProcessConfig());
// Populate the grid
@@ -135,27 +132,21 @@ namespace QuestAppLauncher
/// <returns></returns>
IEnumerator ProcessConfig()
{
// Load config
ConfigPersistence.LoadConfig(this.config);
ProcessGridSize();
// Load configuration
Config config = new Config();
ConfigPersistence.LoadConfig(config);
SetGridSize(config.gridSize.rows, config.gridSize.cols);
yield return null;
}
private void ProcessGridSize()
public void SetGridSize(int rows, int cols)
{
// Make sure grid size have sane value
if (0 == this.config.gridSize.cols && 0 == this.config.gridSize.rows)
{
// If not initialized, default to 3x3
this.config.gridSize.cols = 3;
this.config.gridSize.rows = 3;
}
this.config.gridSize.cols = Math.Min(this.config.gridSize.cols, 10);
this.config.gridSize.cols = Math.Max(this.config.gridSize.cols, 1);
this.config.gridSize.rows = Math.Min(this.config.gridSize.rows, 50);
this.config.gridSize.rows = Math.Max(this.config.gridSize.rows, 1);
cols = Math.Min(cols, 10);
cols = Math.Max(cols, 1);
rows = Math.Min(rows, 10);
rows = Math.Max(rows, 1);
// Get cell size, spacing & padding from the grid layout
var gridLayoutGroup = this.gridContent.GetComponent<GridLayoutGroup>();
@@ -167,17 +158,24 @@ namespace QuestAppLauncher
var spaceY = gridLayoutGroup.spacing.y;
// Width = horizontal padding + # cols * cell width + (# cols - 1) * horizontal spacing
var width = paddingX + this.config.gridSize.cols * cellWidth + (this.config.gridSize.cols - 1) * spaceX;
var width = paddingX + cols * cellWidth + (cols - 1) * spaceX;
// Height = vertical padding + # rows * cell height + (# rows - 1) * veritcal spacing + a bit more to show there are more elements
var height = paddingY + this.config.gridSize.rows * cellHeight + (this.config.gridSize.rows - 1) * spaceY + 120;
var height = paddingY + rows * cellHeight + (rows - 1) * spaceY + 120;
Debug.Log(string.Format("Setting grid size to {0} x {1} cells", this.config.gridSize.cols, this.config.gridSize.rows));
Debug.Log(string.Format("Setting grid size to {0} x {1} cells", cols, rows));
Debug.Log(string.Format("Grid size calculated width x height: {0} x {1}", width, height));
// Adjust canvas rect transform
var canvasRectTransform = this.canvas.GetComponent<RectTransform>();
canvasRectTransform.sizeDelta = new Vector2(width, height);
// Adjust grid container rect transform
var gridTransform = this.gridContainer.GetComponent<RectTransform>();
gridTransform.sizeDelta = new Vector2(width, height);
// Adjust grid container Y position to maintain constant height.
// TODO: Figure out a way to adjust UI to avoid this calculation in code
var gridPosition = new Vector3(gridTransform.anchoredPosition3D.x,
(float)((gridTransform.rect.height - 2000) / 2.0),
gridTransform.anchoredPosition3D.z);
gridTransform.anchoredPosition3D = gridPosition;
// Adjust scroll view rect transform
var scrollViewRectTransform = this.scrollView.GetComponent<RectTransform>();
@@ -211,7 +209,7 @@ namespace QuestAppLauncher
// Add current package name to excludedPackageNames to filter it out
excludedPackageNames.Add(currentActivity.Call<string>("getPackageName"));
//This is a file containing packageNames that will be excluded
// This is a file containing packageNames that will be excluded
var excludedPackageNamesFilePath = Path.Combine(persistentDataPath, ExcludedPackagesFile);
if (File.Exists(excludedPackageNamesFilePath))
{
@@ -239,13 +237,11 @@ namespace QuestAppLauncher
continue;
}
packageNameToAppName.Add(packageName, (i, appName));
Debug.Log("[" + i + "] package: " + packageName + ", name: " + appName);
yield return null;
}
yield return null;
// Override app names, if any
// This is just a file with comma-separated packageName,appName pairs
var appNameOverrideFilePath = Path.Combine(persistentDataPath, AppNameOverrideFile);
@@ -283,6 +279,8 @@ namespace QuestAppLauncher
Debug.Log("Found file: " + iconFileName);
iconOverrides[entry] = Path.Combine(iconOverridePath, iconFileName);
}
yield return null;
}
}
@@ -330,7 +328,6 @@ namespace QuestAppLauncher
var texture = new Texture2D(2, 2, TextureFormat.RGB24, false);
texture.filterMode = FilterMode.Trilinear;
texture.anisoLevel = 16;
//texture.Resize(144, 100, TextureFormat.RGB24, false);
texture.LoadImage(bytesIcon);
var rect = new Rect(0, 0, texture.width, texture.height);
image.sprite = Sprite.Create(texture, rect, new Vector2(0.5f, 0.5f));
+74 -15
View File
@@ -1,38 +1,60 @@
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 scrollView;
public GameObject gridContainer;
public GameObject openSettingsButton;
public GameObject closeSettingsButton;
public GameObject settingsView;
public GameObject settingsContainer;
public GameObject gridCols;
public GameObject gridColsText;
public GameObject gridRows;
public GameObject gridRowsText;
public GameObject gridPopulation;
private Config config = new Config();
public void OpenSettings()
{
Debug.Log("Open Settings");
scrollView.SetActive(false);
openSettingsButton.SetActive(false);
closeSettingsButton.SetActive(true);
settingsView.SetActive(true);
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);
}
public void CloseSettings()
{
Debug.Log("Close Settings");
scrollView.SetActive(true);
openSettingsButton.SetActive(true);
closeSettingsButton.SetActive(false);
settingsView.SetActive(false);
}
// Resize grid if necessary
ResizeGrid();
public void ResizeGrid(int selection)
{
Debug.Log("Resize grid: " + selection);
Debug.Log("Close Settings");
this.gridContainer.SetActive(true);
this.openSettingsButton.SetActive(true);
this.closeSettingsButton.SetActive(false);
this.settingsContainer.SetActive(false);
}
public void DeleteExcludedApksFile()
@@ -40,5 +62,42 @@ namespace QuestAppLauncher
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 ResizeGrid()
{
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)
{
// Nothing was resized, so no work to do
return;
}
Debug.Log(string.Format("Resizing grid: {0} x {1}", cols, rows));
// Update configuration
this.config.gridSize.cols = cols;
this.config.gridSize.rows = rows;
ConfigPersistence.SaveConfig(this.config);
// Update grid size
this.gridPopulation.GetComponent<GridPopulation>().SetGridSize(this.config.gridSize.rows, this.config.gridSize.cols);
}
}
}
-51
View File
@@ -5,58 +5,7 @@ EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/OVROverlay.unity
guid: d31b44aac77e1684d861792b23d46a8b
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/StartScene.unity
guid: 071fba5195bd4b04eab8668985aa1683
- enabled: 0
path: Assets/Oculus/Avatar/Samples/Controllers/Controllers.unity
guid: 2a83dd010542d2744bf59af99b4bc47c
- enabled: 0
path: Assets/OVRInputSelection/Scenes/main.unity
guid: aaffd3596304a76439cf35f76e149abc
- enabled: 0
path: Assets/OVRInputSelection/Scenes/selection_all.unity
guid: 96e237f36213c0f45aa364963e1977cf
- enabled: 0
path: Assets/OVRInputSelection/Scenes/selection_physics.unity
guid: e46f6a64d9f346d4aa57395c1f033060
- enabled: 0
path: Assets/OVRInputSelection/Scenes/selection_raw.unity
guid: d2f845eed230326489e720a9e91e4a8b
- enabled: 0
path: Assets/OVRInputSelection/Scenes/selection_ui.unity
guid: 7adfd19eba27b40748b2a0f7ae856c08
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/MixedRealityCapture.unity
guid: 24872d3c3760f23498f41ecb019ea5cd
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/AvatarGrab.unity
guid: 941c413af7c367d40aab0725f5a59530
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/CustomControllers.unity
guid: e0f49aa4174f98941b88699b5fecddc0
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/CustomHands.unity
guid: a4f984fcee593d2418cc61f4a993d46d
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/DebugUI.unity
guid: 34004346bd7dcbf4fbfd78d2f12e4451
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/DistanceGrab.unity
guid: 24f58b3f0ca02d44eaec7f50bca538f2
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/GuardianBoundarySystem.unity
guid: 486e0749a87daee48a6d3cf7470e5f52
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/Locomotion.unity
guid: 024cd9dcd49bd8f46a6bea03aa8a21bb
- enabled: 1
path: Assets/Scenes/QuestAppLauncher.unity
guid: dca0720aceedefc46b483f0277b30d6a
- enabled: 0
path: Assets/Oculus/SampleFramework/Usage/Stereo180Video.unity
guid: 11cf8fa7bf3deb04db11bd170c0b4338
m_configObjects: {}