-
Notifications
You must be signed in to change notification settings - Fork 0
/
Visuals.cs
86 lines (72 loc) · 2.12 KB
/
Visuals.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
76
77
78
79
80
81
82
83
84
85
86
//
// Cuboid (http://github.com/arjonagelhout/cuboid)
// Copyright (c) 2023 Arjo Nagelhout
//
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Cuboid.UI
{
/// <summary>
/// Class for displaying world axes and world origin
/// </summary>
public class Visuals : MonoBehaviour
{
// GameObjects
[SerializeField] private GameObject _worldXAxis;
[SerializeField] private GameObject _worldYAxis;
[SerializeField] private GameObject _worldZAxis;
[SerializeField] private GameObject _worldOrigin;
[SerializeField] private GameObject _worldYGrid;
private Action<bool> _onShowWorldAxesChanged;
private Action<bool> _onShowWorldYGridChanged;
private App _app;
private void Start()
{
_app = App.Instance;
_onShowWorldAxesChanged = OnShowWorldAxesChanged;
_onShowWorldYGridChanged = OnShowWorldYGridChanged;
Register();
}
private void OnShowWorldAxesChanged(bool visible)
{
_worldXAxis.SetActive(visible);
_worldYAxis.SetActive(visible);
_worldZAxis.SetActive(visible);
_worldOrigin.SetActive(visible);
}
private void OnShowWorldYGridChanged(bool visible)
{
_worldYGrid.SetActive(visible);
}
private void Register()
{
if (_app != null)
{
_app.ShowWorldAxes.Register(_onShowWorldAxesChanged);
_app.ShowWorldYGrid.Register(_onShowWorldYGridChanged);
}
}
private void Unregister()
{
if (_app != null)
{
_app.ShowWorldAxes.Unregister(_onShowWorldAxesChanged);
_app.ShowWorldYGrid.Unregister(_onShowWorldYGridChanged);
}
}
private void OnDestroy()
{
Unregister();
}
private void OnDisable()
{
Unregister();
}
private void OnEnable()
{
Register();
}
}
}