Skip to content

Commit 2e289af

Browse files
author
Wing Chau
committed
Merge branch 'release/0.2.0-alpha'
2 parents 266d3d2 + 202d095 commit 2e289af

19 files changed

+662
-22
lines changed

Assets/Scenes/StartScene.unity

Lines changed: 274 additions & 13 deletions
Large diffs are not rendered by default.

Assets/Scripts/MenuFunctions.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
using UnityEngine;
44
using UnityEngine.SceneManagement;
55
using UnityEngine.UI;
6+
using UnityEngine.EventSystems;
7+
using Utilities;
68

7-
public class MenuFunctions : MonoBehaviour {
9+
public class MenuFunctions : MonoBehaviour, IGvrPointerHoverTarget {
810

911
[SerializeField]
1012
private float speed , maxSize, minSize , incrementBy ,decrementBy;
@@ -20,13 +22,16 @@ public class MenuFunctions : MonoBehaviour {
2022
[SerializeField]
2123
Image image;
2224

25+
[SerializeField]
26+
private GameObject m_player; // TODO implement super class to handle target object mapping
27+
2328
private float crtScale,crtAlpha = 0.0f;
24-
29+
2530
// Use this for initialization
2631
void Start () {
27-
32+
2833
}
29-
34+
3035
public void OnStartJourneyButton()
3136
{
3237
SceneManager.LoadScene(1);
@@ -45,13 +50,24 @@ public void OnHoverButton()
4550
InvokeRepeating("IncrementScale", speed,speed);
4651
CancelInvoke("DecrementScale");
4752
print("Incrementing" + " " + incrementAlphaBy + " " + decrementAlphaBy);
53+
54+
ExecuteEvents.Execute<IGvrPointerHoverEvent>(m_player, null, (x, y) => x.OnGvrPointerHover(this));
55+
// TODO move to super class
56+
4857
}
4958
public void OnHoverExitButton()
5059
{
5160
CancelInvoke("DecrementScale");
5261
CancelInvoke("IncrementScale");
5362
panel.localScale = new Vector3(minSize, minSize, minSize);
5463
print("Decrementing");
64+
65+
ExecuteEvents.Execute<IGvrPointerHoverEvent>(m_player, null, (x, y) => x.OnGvrPointerHoverExit());
66+
// TODO move to super class
67+
}
68+
69+
void IGvrPointerHoverTarget.Execute() {
70+
OnStartJourneyButton();
5571
}
5672

5773
private void IncrementScale()

Assets/Scripts/Utilities.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using UnityEngine;
5+
using UnityEngine.UI;
6+
using Utilities;
7+
8+
public class GvrPointerHoverEvent : MonoBehaviour, IGvrPointerHoverEvent {
9+
10+
[SerializeField] private GameObject m_progressBar;
11+
[SerializeField] private Image m_progress;
12+
13+
private float m_hoverTime = 2.0f; // hover 2s to preform as click
14+
private bool m_onHover = false;
15+
private bool m_reset = false;
16+
17+
private IGvrPointerHoverTarget m_target;
18+
19+
// Use this for initialization
20+
void Start () {
21+
m_progress.fillAmount = 0;
22+
}
23+
24+
// Update is called once per frame
25+
void Update () {
26+
if (m_onHover) {
27+
ActiveProgressBar();
28+
} else {
29+
if (m_reset)
30+
ResetProgressBar();
31+
}
32+
}
33+
34+
void IGvrPointerHoverEvent.OnGvrPointerHover(IGvrPointerHoverTarget target) {
35+
m_target = target;
36+
m_onHover = true;
37+
38+
Debug.Log("on hover");
39+
}
40+
41+
void IGvrPointerHoverEvent.OnGvrPointerHoverExit() {
42+
m_onHover = false;
43+
44+
Debug.Log("hover exit");
45+
}
46+
47+
void ActiveProgressBar() {
48+
m_progressBar.SetActive(true);
49+
m_reset = true;
50+
51+
if (m_progress.fillAmount < 1) {
52+
m_progress.fillAmount += 1.0f / m_hoverTime * Time.deltaTime;
53+
} else {
54+
m_target.Execute();
55+
}
56+
}
57+
58+
void ResetProgressBar() {
59+
m_progressBar.SetActive(false);
60+
m_reset = false;
61+
62+
m_progress.fillAmount = 0;
63+
}
64+
}

Assets/Scripts/Utilities/GvrPointerHoverEvent.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.EventSystems;
5+
6+
namespace Utilities {
7+
8+
internal interface IGvrPointerHoverEvent : IEventSystemHandler {
9+
10+
void OnGvrPointerHover(IGvrPointerHoverTarget target);
11+
void OnGvrPointerHoverExit();
12+
}
13+
}

Assets/Scripts/Utilities/IGvrPointerHoverEvent.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.EventSystems;
5+
6+
namespace Utilities {
7+
8+
internal interface IGvrPointerHoverTarget : IEventSystemHandler{
9+
10+
void Execute();
11+
}
12+
}

Assets/Scripts/Utilities/IGvrPointerHoverTarget.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
6+
public class OnPointerHover : MonoBehaviour {
7+
8+
private float hoverTime = 3.0f;
9+
[SerializeField] private Image progressBar;
10+
11+
// Use this for initialization
12+
void Start () {
13+
progressBar.fillAmount = 0;
14+
}
15+
16+
// Update is called once per frame
17+
void Update () {
18+
19+
if (progressBar.fillAmount < 1) {
20+
progressBar.fillAmount += 1.0f / hoverTime * Time.deltaTime;
21+
}
22+
}
23+
}

Assets/Scripts/Utilities/OnPointerHover.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Textures/progress bar.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading

Assets/Textures/progress bar/progressBar_bg.png.meta

Lines changed: 92 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading

0 commit comments

Comments
 (0)