-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnableSeeThrough.cs
More file actions
43 lines (36 loc) · 1.07 KB
/
EnableSeeThrough.cs
File metadata and controls
43 lines (36 loc) · 1.07 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
using System.Collections;
using Unity.XR.PXR;
using UnityEngine;
public class EnableSeeThrough : MonoBehaviour
{
private Camera mainCamera;
private float enableSeeThroughAfter = 0.1f;
private void Awake()
{
if (mainCamera == null) mainCamera = GetComponent<Camera>();
if (mainCamera)
{
Debug.Log(nameof(ToggleSeeThrough));
StartCoroutine(ToggleSeeThrough(true));
mainCamera.backgroundColor = new Color(0, 0, 0, 0);
mainCamera.clearFlags = CameraClearFlags.SolidColor;
}
else
{
Debug.LogError("A camera must be referenced or be part of this game object");
}
}
private IEnumerator ToggleSeeThrough(bool enable)
{
yield return new WaitForSeconds(enableSeeThroughAfter);
PXR_Boundary.EnableSeeThroughManual(enable);
Debug.Log($"See through is set to ({enabled})");
}
private void OnApplicationPause(bool pause)
{
if (!pause)
{
PXR_Boundary.EnableSeeThroughManual(true);
}
}
}