xr in unity code example

Example 1: unity onpointerdown

//Attach this script to the GameObject you would like to have mouse clicks detected on
//This script outputs a message to the Console when a click is currently detected or when it is released on the GameObject with this script attached

using UnityEngine;
using UnityEngine.EventSystems;

public class Example : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
    //Detect current clicks on the GameObject (the one with the script attached)
    public void OnPointerDown(PointerEventData pointerEventData)
    {
        //Output the name of the GameObject that is being clicked
        Debug.Log(name + "Game Object Click in Progress");
    }

    //Detect if clicks are no longer registering
    public void OnPointerUp(PointerEventData pointerEventData)
    {
        Debug.Log(name + "No longer being clicked");
    }
}

Example 2: slomotion in unity 3d

using UnityEngine;
using System.Collections;

public class SlowMotion : MonoBehaviour {

float currentAmount = 0f;
float maxAmount = 5f;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

if(Input.GetKeyDown ("insert any key here")){

if(Time.timeScale == 1.0f)
Time.timeScale = 0.3f;

else

Time.timeScale = 1.0f;
Time.fixedDeltaTime = 0.02f * Time.timeScale;
}


if(Time.timeScale == 0.03f){

currentAmount += Time.deltaTime;
}

if(currentAmount > maxAmount){

currentAmount = 0f;
Time.timeScale = 1.0f;

}

}
}