<commit_before>---
title: VR
permalink: /vr/
---
> VR Projects

1. Learn and understand VR fundamentals
2. Made with Unity & coded in C#
3. Made with GoogleVr SDK and for Android platform

[1.LOFT](#loft)[2.MAZE](#maze)|[3.PLANETS](#planets)|[4.DISTANCES](#distances)

# Loft

### Objectives

The idea is to immerse the person into a 'real measures' loft and to give the possibility of Like/Dislike certain items and parts of the loft. Once the person has visited upstairs and downstairs we can see which are the objects that he/she liked and the ones he/she disliked through the use of a mini realtime DB in VR.

![intro](https://cloud.githubusercontent.com/assets/17754060/21591996/e4e36066-d0df-11e6-8146-827f9b2e7819.png)

### Code

> An example of Interaction design script from the 'Maze'.

###typeWriterEffect

```c#
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class typeWriterEffect : MonoBehaviour
{
	public float delay = 0.1f;
	public string fullText;
	private string currentText = "";

	IEnumerator Start () {
		StartCoroutine(ShowText());
		yield return new WaitForSeconds(4.0f);
		Destroy(gameObject);
	}

	IEnumerator ShowText()
	{
		for(int i = 0; i < (fullText.Length)+1; i++)
		{
			currentText = fullText.Substring(0,i);
			this.GetComponent<Text>().text = currentText;
			yield return new WaitForSeconds(delay);
		}
	}
}
```
==================
###ManagerScript

```c#
using UnityEngine;
using System.Collections;

public class ManagerScript : MonoBehaviour 
{
	public int likes;
	public int dislikes;
}
```
==================
###SimpleLoad

```c#
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SimpleLoad : MonoBehaviour 
{
	public GameObject managerScript;
	public Text textLoaderL;
	public Text textLoaderD;
	public Text result;
	public int lks;
	public int dlks;

	public void Load()
	{
		ManagerScript script = managerScript.GetComponent <ManagerScript> ();

		script.likes = ES2.Load<int> ("likes");
		lks = script.likes;
		textLoaderL.text = script.likes.ToString();

		script.dislikes = ES2.Load<int> ("dislikes");
		textLoaderD.text = script.dislikes.ToString();
		dlks = script.dislikes;

		if(lks > dlks)
		{
			result.text = "You really like this place!";
		}
		else
		{
			result.text = "Not for you it seems!";
		}
	}
}

```
==================
###SimpleSave

```c#
using UnityEngine;
using System.Collections;

public class SimpleSave : MonoBehaviour 
{
	public GameObject managerScript;

	public void Save()
	{
		ManagerScript script = managerScript.GetComponent <ManagerScript> ();

		ES2.Save (script.likes, "likes");
		ES2.Save (script.dislikes, "dislikes");
	}
}
<commit_msg>Update vr.md<commit_after>---
title: VR
permalink: /vr/
---
> VR Projects

1. Learn and understand VR fundamentals
2. Made with Unity & coded in C#
3. Made with GoogleVr SDK and for Android platform

[1.LOFT](#loft)|[2.MAZE](#maze)|[3.PLANETS](#planets)|[4.DISTANCES](#distances)

# Loft

### Objectives

We immerse the person into a loft with real measures and give them the possibility to Like/Dislike certain items in it. Once the person has visited upstairs and downstairs we can see which are the objects that he/she liked and the ones he/she disliked through the use of a mini realtime DB in VR.

![intro](https://cloud.githubusercontent.com/assets/17754060/21591996/e4e36066-d0df-11e6-8146-827f9b2e7819.png)

### Code

> An example of Interaction design script from the 'Loft'.

#### typeWriterEffect

```c#
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class typeWriterEffect : MonoBehaviour
{
	public float delay = 0.1f;
	public string fullText;
	private string currentText = "";

	IEnumerator Start () {
		StartCoroutine(ShowText());
		yield return new WaitForSeconds(4.0f);
		Destroy(gameObject);
	}

	IEnumerator ShowText()
	{
		for(int i = 0; i < (fullText.Length)+1; i++)
		{
			currentText = fullText.Substring(0,i);
			this.GetComponent<Text>().text = currentText;
			yield return new WaitForSeconds(delay);
		}
	}
}
```
#### ManagerScript
```c#
using UnityEngine;
using System.Collections;

public class ManagerScript : MonoBehaviour 
{
	public int likes;
	public int dislikes;
}
```

#### SimpleLoad
```c#
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SimpleLoad : MonoBehaviour 
{
	public GameObject managerScript;
	public Text textLoaderL;
	public Text textLoaderD;
	public Text result;
	public int lks;
	public int dlks;

	public void Load()
	{
		ManagerScript script = managerScript.GetComponent <ManagerScript> ();

		script.likes = ES2.Load<int> ("likes");
		lks = script.likes;
		textLoaderL.text = script.likes.ToString();

		script.dislikes = ES2.Load<int> ("dislikes");
		textLoaderD.text = script.dislikes.ToString();
		dlks = script.dislikes;

		if(lks > dlks)
		{
			result.text = "You really like this place!";
		}
		else
		{
			result.text = "Not for you it seems!";
		}
	}
}

```

#### SimpleSave
```c#
using UnityEngine;
using System.Collections;

public class SimpleSave : MonoBehaviour 
{
	public GameObject managerScript;

	public void Save()
	{
		ManagerScript script = managerScript.GetComponent <ManagerScript> ();

		ES2.Save (script.likes, "likes");
		ES2.Save (script.dislikes, "dislikes");
	}
}

{'fraction_non_alphanumeric': 0.1291422079151676, 'fraction_numerical': 0.02158682067790191, 'mean_word_length': 4.367886178861789, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5760954', 'n_tokens_mistral': 1921, 'n_tokens_neox': 1754, 'n_words': 508}