CreateManager.cs
1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
public class CreateManager : MonoBehaviour
{
public ARRaycastManager raycastMgr;
public ARPlane _ARPlane;
public GameObject placeObject;
private List<ARRaycastHit> hits = new List<ARRaycastHit>();
private List<GameObject> obj = new List<GameObject>();
bool created;
public bool gameoverTimerActivate;
/// <summary>
/// Game Over Script here
/// </summary>
private float deadTime;
public GameObject gOverPanel;
// Start is called before the first frame update
void Start()
{
placeObject.SetActive(false);
deadTime = 0;
created = false;
gOverPanel.SetActive(false);
}
// Update is called once per frame
void Update()
{
if(created == false)
{
UpdateCenterObject();
}
if (placeObject.activeSelf == true) // 활성화 상태면
{
deadTime += Time.deltaTime; // 1초씩 타임 재기
}
checkDead();
}
void UpdateCenterObject()
{
Vector3 screenCenter = Camera.current.ViewportToScreenPoint(new Vector3(0.5f, 0.5f));
raycastMgr.Raycast(screenCenter, hits, TrackableType.PlaneWithinPolygon);
if (hits.Count > 0)
{
Pose placementPose = hits[0].pose;
placeObject.SetActive(true);
placeObject.transform.SetPositionAndRotation(placementPose.position, placementPose.rotation);
created = true;
}
}
void checkDead()
{
if (gameoverTimerActivate)
{
if (deadTime >= 5f) // 타임이 10이 되면
{
Time.timeScale = 0; // 일시정지시키고
gOverPanel.SetActive(true); // gameOver 패널을 활성화
//GameOver 텍스트 출력
}
}
}
}