-
Notifications
You must be signed in to change notification settings - Fork 0
/
PassthroughController.cs
75 lines (63 loc) · 1.9 KB
/
PassthroughController.cs
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
//
// Cuboid (http://github.com/arjonagelhout/cuboid)
// Copyright (c) 2023 Arjo Nagelhout
//
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Cuboid
{
public class PassthroughController : MonoBehaviour
{
private App _app;
private Action<bool> _onPassthroughChanged;
[SerializeField] private Camera _mainCamera;
[SerializeField] private OVRManager _ovrManager;
[SerializeField] private OVRPassthroughLayer _passthroughLayer;
private void Start()
{
_app = App.Instance;
_onPassthroughChanged = OnPassthroughChanged;
Register();
_app.Passthrough.Value = true;
}
private void OnPassthroughChanged(bool passthrough)
{
_ovrManager.isInsightPassthroughEnabled = passthrough;
_mainCamera.backgroundColor = passthrough ? Color.clear : Color.black;
_mainCamera.clearFlags = passthrough ? CameraClearFlags.SolidColor : CameraClearFlags.Skybox;
_passthroughLayer.enabled = passthrough;
Debug.Log("Changed passthrough");
Debug.Log(_mainCamera.clearFlags);
Debug.Log(_mainCamera.backgroundColor);
Debug.Log(_ovrManager.isInsightPassthroughEnabled);
}
private void Register()
{
if (_app != null)
{
_app.Passthrough.Register(_onPassthroughChanged);
}
}
private void Unregister()
{
if (_app != null)
{
_app.Passthrough.Unregister(_onPassthroughChanged);
}
}
private void OnEnable()
{
Register();
}
private void OnDisable()
{
Unregister();
}
private void OnDestroy()
{
Unregister();
}
}
}