From 2740bf207ceededa49ba3ae7dd2ab86523214cf8 Mon Sep 17 00:00:00 2001 From: weathon Date: Thu, 18 Jul 2019 10:40:47 +0200 Subject: [PATCH] When pressing Y or B on the controller, the package name of the selected App will be added to the excluded list and the scene will be reloaded; --- Assets/Scenes/QuestAppLauncher.unity | 17 ++++++++++++++--- Assets/Scripts/GridPopulation.cs | 23 ++++++++++++++++++++++- Assets/Scripts/OnInteraction.cs | 11 +++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/Assets/Scenes/QuestAppLauncher.unity b/Assets/Scenes/QuestAppLauncher.unity index 0e02f23..d8874c3 100644 --- a/Assets/Scenes/QuestAppLauncher.unity +++ b/Assets/Scenes/QuestAppLauncher.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.017265085, g: 0.037189834, b: 0.03553985, a: 1} + m_IndirectSpecularColor: {r: 0.017265823, g: 0.037191074, b: 0.035541035, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -1033,7 +1033,7 @@ MonoBehaviour: m_EditorClassIdentifier: trackingSpace: {fileID: 881994610} primaryButton: 8192 - secondaryButton: 1024 + secondaryButton: 10 excludeLayers: serializedVersion: 2 m_Bits: 0 @@ -1093,7 +1093,18 @@ MonoBehaviour: Version=0.0.0.0, Culture=neutral, PublicKeyToken=null onSecondarySelect: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 1113839883} + m_MethodName: OnSelectedPressedBorY + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_TypeName: ControllerSelection.OVRRawRaycaster+SelectionCallback, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null activeController: 0 diff --git a/Assets/Scripts/GridPopulation.cs b/Assets/Scripts/GridPopulation.cs index 878e575..adbe51a 100644 --- a/Assets/Scripts/GridPopulation.cs +++ b/Assets/Scripts/GridPopulation.cs @@ -8,6 +8,7 @@ using UnityEngine.XR; using System; using Oculus.Platform; using TMPro; +using UnityEngine.SceneManagement; namespace QuestAppLauncher { @@ -52,7 +53,7 @@ namespace QuestAppLauncher #region Private Functions /// - /// Static method for lauching an Android app + /// Static method for launching an Android app /// /// static public void LaunchApp(string packageId) @@ -85,6 +86,26 @@ namespace QuestAppLauncher } } + /// + /// Static method to add a package name to the excludedFile + /// + /// + static public void AddAppToExcludedFile(string packageName) + { + var persistentDataPath = UnityEngine.Application.persistentDataPath; + Debug.Log("Persistent data path: " + persistentDataPath); + + var excludedPackageNamesFilePath = Path.Combine(persistentDataPath, ExcludedPackagesFile); + + using (StreamWriter writer = File.AppendText(excludedPackageNamesFilePath)) + { + writer.WriteLine(packageName); + Debug.Log($"Added package {packageName} to the excluded file {excludedPackageNamesFilePath}"); + } + + SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); + } + /// /// Populate the grid from installed apps /// diff --git a/Assets/Scripts/OnInteraction.cs b/Assets/Scripts/OnInteraction.cs index 79c440e..3972dea 100644 --- a/Assets/Scripts/OnInteraction.cs +++ b/Assets/Scripts/OnInteraction.cs @@ -41,6 +41,17 @@ public class OnInteraction : MonoBehaviour } } + public void OnSelectedPressedBorY(Transform t) + { + var appEntry = t.gameObject.GetComponent("AppEntry") as AppEntry; + if (null != appEntry) + { + // Launch app + Debug.Log("Hiding: " + appEntry.appName + " (package id: " + appEntry.packageId + ")"); + QuestAppLauncher.GridPopulation.AddAppToExcludedFile(appEntry.packageId); + } + } + void EnableBorder(Transform t, bool enable) { var border = t.Find("Border");