Skip to content

Instantly share code, notes, and snippets.

@nabesi777
Created September 30, 2018 07:56
Show Gist options
  • Save nabesi777/3ed7b0d22f68b570737cba56677670ad to your computer and use it in GitHub Desktop.
Save nabesi777/3ed7b0d22f68b570737cba56677670ad to your computer and use it in GitHub Desktop.
視点ポインターでシーン移行
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Main : MonoBehaviour
{
public GameObject button;
private bool count;
private float time;
// Use this for initialization
void Start()
{
time = 0;
count = false;
}
// Update is called once per frame
void Update()
{
if (count)
{ //countがtrueの時は時間が進む
time += Time.deltaTime;
if (time >= 1)
{//一秒以上見つめるとPlayモードへ移行
SceneManager.LoadScene("Play");
}
}
}
public void OnEnterPointer()
{
count = true;
}
//視点がオブジェクトから外れたら
public void OnExitPonter()
{
count = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment