Files
QuestAppLauncher/Assets/Scripts/OnInteraction.cs
tverona1 18dbf110c9 Refactored code a bit
- Refactored GridPopulation class into two classes: GridPopulation handles populating the grid UI and AppProcessor handles processing the app entries.
2019-08-08 23:52:36 -07:00

66 lines
2.0 KiB
C#

using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace QuestAppLauncher
{
public class OnInteraction : MonoBehaviour
{
protected Material oldHoverMat;
public Material yellowMat;
public Material backIdle;
public Material backACtive;
public UnityEngine.UI.Text outText;
public void OnHoverEnter(Transform t)
{
var appEntry = t.gameObject.GetComponent("AppEntry") as AppEntry;
if (null != appEntry)
{
// Enable border
EnableBorder(t, true);
}
}
public void OnHoverExit(Transform t)
{
var appEntry = t.gameObject.GetComponent("AppEntry") as AppEntry;
if (null != appEntry)
{
// Disable border
EnableBorder(t, false);
}
}
public void OnSelected(Transform t)
{
var appEntry = t.gameObject.GetComponent("AppEntry") as AppEntry;
if (null != appEntry)
{
// Launch app
Debug.Log("Launching: " + appEntry.appName + " (package id: " + appEntry.packageId + ")");
AppProcessor.LaunchApp(appEntry.packageId);
}
}
public void OnSelectedPressedBorY(Transform t)
{
var appEntry = t.gameObject.GetComponent("AppEntry") as AppEntry;
if (null != appEntry)
{
// Add package name to excluded file
Debug.Log("Hiding: " + appEntry.appName + " (package id: " + appEntry.packageId + ")");
AppProcessor.AddAppToExcludedFile(appEntry.packageId);
// Remove ourselves from the gridview
Destroy(t.gameObject);
}
}
void EnableBorder(Transform t, bool enable)
{
var border = t.Find("Border");
border?.gameObject.SetActive(enable);
}
}
}