Skip to content

Commit d338b55

Browse files
committedDec 12, 2018
Add Scenes with their scripts
1 parent 81542d9 commit d338b55

18 files changed

+346
-0
lines changed
 

‎Assets/Scenes.meta

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Assets/Scenes/1-Instructions.unity

53.4 KB
Binary file not shown.

‎Assets/Scenes/1-Instructions.unity.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Assets/Scenes/2-Loading.unity

20.7 KB
Binary file not shown.

‎Assets/Scenes/2-Loading.unity.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Assets/Scenes/3-Main.unity

54.8 KB
Binary file not shown.

‎Assets/Scenes/3-Main.unity.meta

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Assets/Scripts.meta

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Assets/Scripts/AboutScreen.cs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
using UnityEngine.SceneManagement;
4+
5+
public class AboutScreen : MonoBehaviour
6+
{
7+
#region PUBLIC_METHODS
8+
public void OnStartAR()
9+
{
10+
SceneManager.LoadScene("2-Loading");
11+
}
12+
#endregion // PUBLIC_METHODS
13+
14+
15+
#region MONOBEHAVIOUR_METHODS
16+
void Update()
17+
{
18+
if (Input.GetKeyUp(KeyCode.Return))
19+
{
20+
// Treat 'Return' key as pressing the Close button and dismiss the About Screen
21+
OnStartAR();
22+
}
23+
else if (Input.GetKeyUp(KeyCode.JoystickButton0))
24+
{
25+
// Similar to above except detecting the first Joystick button
26+
// Allows external controllers to dismiss the About Screen
27+
// On an ODG R7 this is the select button
28+
OnStartAR();
29+
}
30+
else if (Input.GetKeyUp(KeyCode.Escape))
31+
{
32+
#if UNITY_EDITOR
33+
UnityEditor.EditorApplication.isPlaying = false;
34+
#elif UNITY_ANDROID
35+
// On Android, the Back button is mapped to the Esc key
36+
Application.Quit();
37+
#endif
38+
}
39+
}
40+
#endregion // MONOBEHAVIOUR_METHODS
41+
}

‎Assets/Scripts/AboutScreen.cs.meta

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Assets/Scripts/AsyncSceneLoader.cs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using UnityEngine;
2+
using UnityEngine.UI;
3+
using System.Collections;
4+
using UnityEngine.SceneManagement;
5+
6+
public class AsyncSceneLoader : MonoBehaviour
7+
{
8+
#region PUBLIC_MEMBERS
9+
public float loadingDelay = 5.0F;
10+
#endregion //PUBLIC_MEMBERS
11+
12+
13+
#region MONOBEHAVIOUR_METHODS
14+
void Start()
15+
{
16+
StartCoroutine(LoadNextSceneAfter(loadingDelay));
17+
}
18+
#endregion //MONOBEHAVIOUR_METHODS
19+
20+
21+
#region PRIVATE_METHODS
22+
private IEnumerator LoadNextSceneAfter(float seconds)
23+
{
24+
yield return new WaitForSeconds(seconds);
25+
26+
SceneManager.LoadScene("3-Main");
27+
}
28+
#endregion //PRIVATE_METHODS
29+
}

‎Assets/Scripts/AsyncSceneLoader.cs.meta

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Assets/Scripts/LoadingScreen.cs

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using UnityEngine;
2+
using UnityEngine.UI;
3+
using System.Collections;
4+
using UnityEngine.SceneManagement;
5+
6+
public class LoadingScreen : MonoBehaviour
7+
{
8+
#region PRIVATE_MEMBER_VARIABLES
9+
private bool mChangeLevel = true;
10+
private RawImage mUISpinner;
11+
#endregion // PRIVATE_MEMBER_VARIABLES
12+
13+
14+
#region MONOBEHAVIOUR_METHODS
15+
void Start()
16+
{
17+
mUISpinner = GetComponentInChildren<RawImage>();
18+
Application.backgroundLoadingPriority = ThreadPriority.Low;
19+
mChangeLevel = true;
20+
}
21+
22+
void Update()
23+
{
24+
if (mUISpinner)
25+
mUISpinner.rectTransform.Rotate(Vector3.forward, 90.0f * Time.deltaTime);
26+
27+
if (mChangeLevel)
28+
{
29+
LoadNextSceneAsync();
30+
mChangeLevel = false;
31+
}
32+
}
33+
#endregion // MONOBEHAVIOUR_METHODS
34+
35+
36+
#region PRIVATE_METHODS
37+
private void LoadNextSceneAsync()
38+
{
39+
SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex + 1);
40+
}
41+
42+
#endregion // PRIVATE_METHODS
43+
}

‎Assets/Scripts/LoadingScreen.cs.meta

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using UnityEngine;
2+
using EasyAR;
3+
4+
public class MainImageTargetBehaviour : ImageTargetBehaviour
5+
{
6+
protected override void Awake()
7+
{
8+
base.Awake();
9+
TargetFound += OnTargetFound;
10+
TargetLost += OnTargetLost;
11+
TargetLoad += OnTargetLoad;
12+
TargetUnload += OnTargetUnload;
13+
}
14+
15+
void OnTargetFound(TargetAbstractBehaviour behaviour)
16+
{
17+
Debug.Log("Found: " + Target.Id);
18+
}
19+
20+
void OnTargetLost(TargetAbstractBehaviour behaviour)
21+
{
22+
Debug.Log("Lost: " + Target.Id);
23+
}
24+
25+
void OnTargetLoad(ImageTargetBaseBehaviour behaviour, ImageTrackerBaseBehaviour tracker, bool status)
26+
{
27+
Debug.Log("Load target (" + status + "): " + Target.Id + " (" + Target.Name + ") " + " -> " + tracker);
28+
}
29+
30+
void OnTargetUnload(ImageTargetBaseBehaviour behaviour, ImageTrackerBaseBehaviour tracker, bool status)
31+
{
32+
Debug.Log("Unload target (" + status + "): " + Target.Id + " (" + Target.Name + ") " + " -> " + tracker);
33+
}
34+
}

‎Assets/Scripts/MainImageTargetBehaviour.cs.meta

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Assets/Scripts/VideoPlay.cs

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using UnityEngine;
2+
using EasyAR;
3+
4+
public class VideoPlay : ImageTargetBehaviour
5+
{
6+
private bool loaded;
7+
private bool found;
8+
private System.EventHandler videoReayEvent;
9+
private VideoPlayerBaseBehaviour videoPlayer;
10+
public GameObject PlayerLoc;
11+
12+
protected override void Awake()
13+
{
14+
base.Awake();
15+
TargetFound += OnTargetFound;
16+
TargetLost += OnTargetLost;
17+
TargetLoad += OnTargetLoad;
18+
TargetUnload += OnTargetUnload;
19+
}
20+
21+
protected override void Start()
22+
{
23+
videoReayEvent = OnVideoReady;
24+
base.Start();
25+
LoadVideo("Android.mp4");
26+
}
27+
28+
public void SwitchVideo(string video)
29+
{
30+
UnLoadVideo();
31+
LoadVideo(video);
32+
}
33+
34+
public void LoadVideo(string video)
35+
{
36+
videoPlayer = PlayerLoc.GetComponent<VideoPlayerBehaviour>();
37+
if (videoPlayer)
38+
{
39+
videoPlayer.Storage = StorageType.Assets;
40+
videoPlayer.Path = video;
41+
videoPlayer.EnableAutoPlay = true;
42+
videoPlayer.EnableLoop = true;
43+
videoPlayer.Type = VideoPlayerBehaviour.VideoType.Normal;
44+
videoPlayer.VideoReadyEvent += videoReayEvent;
45+
videoPlayer.Open();
46+
}
47+
}
48+
49+
public void UnLoadVideo()
50+
{
51+
if (!videoPlayer)
52+
return;
53+
videoPlayer.VideoReadyEvent -= videoReayEvent;
54+
videoPlayer.Close();
55+
loaded = false;
56+
}
57+
58+
void OnVideoReady(object sender, System.EventArgs e)
59+
{
60+
Debug.Log("Load video success");
61+
VideoPlayerBaseBehaviour player = sender as VideoPlayerBaseBehaviour;
62+
loaded = true;
63+
if (player && found)
64+
player.Play();
65+
}
66+
67+
void OnTargetFound(TargetAbstractBehaviour behaviour)
68+
{
69+
found = true;
70+
if (videoPlayer && loaded)
71+
videoPlayer.Play();
72+
Debug.Log("Found: " + Target.Id);
73+
}
74+
75+
void OnTargetLost(TargetAbstractBehaviour behaviour)
76+
{
77+
found = false;
78+
if (videoPlayer && loaded)
79+
videoPlayer.Pause();
80+
Debug.Log("Lost: " + Target.Id);
81+
}
82+
83+
void OnTargetLoad(ImageTargetBaseBehaviour behaviour, ImageTrackerBaseBehaviour tracker, bool status)
84+
{
85+
Debug.Log("Load target (" + status + "): " + Target.Id + " (" + Target.Name + ") " + " -> " + tracker);
86+
}
87+
88+
void OnTargetUnload(ImageTargetBaseBehaviour behaviour, ImageTrackerBaseBehaviour tracker, bool status)
89+
{
90+
Debug.Log("Unload target (" + status + "): " + Target.Id + " (" + Target.Name + ") " + " -> " + tracker);
91+
}
92+
}

‎Assets/Scripts/VideoPlay.cs.meta

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)