Skip to content

Commit 7a5ef38

Browse files
authored
feat: pause menu (#24)
1 parent a546ea9 commit 7a5ef38

File tree

104 files changed

+4768
-2938
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+4768
-2938
lines changed

Assets/Environment/MainCamera.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Settings;
2+
using System;
3+
using UnityEngine;
4+
using Utils;
5+
using UnityEngine.Rendering.Universal;
6+
using UnityEngine.Serialization;
7+
using View.Overlay;
8+
using View.Settings;
9+
10+
namespace Environment {
11+
public class MainCamera : MonoBehaviour {
12+
[FormerlySerializedAs("_settings")] [Inject] [SerializeField] private OverlayChannel _overlay;
13+
private Camera _camera;
14+
private Camera _overlayCamera;
15+
16+
private void Awake() {
17+
_camera = GetComponent<Camera>();
18+
_overlay.CameraChanged += HandleCameraChanged;
19+
}
20+
21+
private void OnDestroy() {
22+
_overlay.CameraChanged -= HandleCameraChanged;
23+
}
24+
25+
private void HandleCameraChanged(OverlayCamera overlayCamera) {
26+
var data = _camera.GetUniversalAdditionalCameraData();
27+
if (_overlayCamera != null) {
28+
data.cameraStack.Remove(_overlayCamera);
29+
}
30+
if (overlayCamera != null) {
31+
_overlayCamera = overlayCamera.NativeCamera;
32+
data.cameraStack.Add(_overlayCamera);
33+
}
34+
}
35+
36+
private void Start() { }
37+
}
38+
}

Assets/Environment/MainCamera.cs.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Environment/Materials/BoxSDF.mat

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:81d635dd10a1c224256fffd57318f6fa23c74c1252df7737522016eee7c9d160
3-
size 114460
2+
oid sha256:602f91fb7686b8faf278d50799f79ab4b6c33846597c9b82ac9bf93eaa601056
3+
size 114700

Assets/Environment/Models/Folder.fbx.meta

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Environment/Prefabs/Doc.prefab

Lines changed: 17 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Environment/Prefabs/Tape.prefab

Lines changed: 25 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Environment/Shaders/BoxSDF.shader

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ Shader "GUI/BoxSDF"
33
Properties
44
{
55
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
6+
_PaintTex ("Paint Texture", 2D) = "white" {}
67
_Radius ("Radius", Float) = 0.3
78
_StrokeWidth ("Stroke Width", Float) = 0.1
89
_Smoothness ("Smoothness", Float) = 0.01
10+
_Test ("Test", Vector) = (0, 0, 0, 0)
911

1012
[HideInInspector] _StencilComp ("Stencil Comparison", Float) = 8
1113
[HideInInspector] _Stencil ("Stencil ID", Float) = 0
@@ -62,6 +64,7 @@ Shader "GUI/BoxSDF"
6264
float4 color : COLOR;
6365
float2 texcoord : TEXCOORD0;
6466
float4 params : TEXCOORD1;
67+
float4 params2 : TEXCOORD2;
6568
UNITY_VERTEX_INPUT_INSTANCE_ID
6669
};
6770

@@ -72,6 +75,7 @@ Shader "GUI/BoxSDF"
7275
float2 texcoord : TEXCOORD0;
7376
float4 worldPosition : TEXCOORD1;
7477
float4 params : TEXCOORD2;
78+
float4 params2 : TEXCOORD3;
7579
UNITY_VERTEX_OUTPUT_STEREO
7680
};
7781

@@ -82,6 +86,7 @@ Shader "GUI/BoxSDF"
8286
float _StrokeWidth;
8387
float _Smoothness;
8488
float4 _ClipRect;
89+
float4 _Test;
8590

8691
inline float roundBoxSDF(const float2 position, const float2 size, const float radius)
8792
{
@@ -104,6 +109,7 @@ Shader "GUI/BoxSDF"
104109

105110
output.texcoord = input.texcoord;
106111
output.params = input.params;
112+
output.params2 = input.params2;
107113
output.color = input.color;
108114
return output;
109115
}
@@ -137,6 +143,13 @@ Shader "GUI/BoxSDF"
137143
distance
138144
);
139145

146+
float paint = tex2D(_PaintTex, (uv * size + input.params2.xy) * 0.01).b;
147+
// color.rgb += lerp(input.params2.z, input.params2.w, paint);
148+
paint -= _Test.x;
149+
paint *= _Test.y;
150+
paint *= input.params2.z;
151+
color.rgb += paint;
152+
140153
#ifdef UNITY_UI_CLIP_RECT
141154
color.a *= get2DClipping(input.worldPosition.xy, _ClipRect);
142155
#endif

Assets/Framework/GameManager.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ public class GameManager : MonoBehaviour {
1212
[Inject] public AudioManager Audio;
1313

1414
private GameMode _currentMode;
15-
private bool _isSwitching;
15+
private GameMode _switchingTo;
16+
17+
private bool ISSwitching => !ReferenceEquals(_switchingTo, null);
1618

1719
public void RequestMode(GameMode mode) {
20+
if (_switchingTo == mode || _currentMode == mode) {
21+
return;
22+
}
23+
1824
StartCoroutine(SwitchMode(mode));
1925
}
2026

@@ -70,21 +76,23 @@ private IEnumerator Reload() {
7076
#endif
7177

7278
private IEnumerator SwitchMode(GameMode mode) {
73-
yield return new WaitUntil(() => !_isSwitching);
74-
75-
if (_currentMode == mode) {
79+
if (_switchingTo == mode || _currentMode == mode) {
7680
yield break;
7781
}
7882

79-
_isSwitching = true;
83+
if (ISSwitching) {
84+
yield return new WaitUntil(() => !ISSwitching);
85+
}
86+
87+
_switchingTo = mode;
8088
if (!ReferenceEquals(_currentMode, null)) {
8189
yield return _currentMode.OnEnd();
8290
}
8391

8492
_currentMode = mode;
8593
yield return _currentMode.OnStart();
8694

87-
_isSwitching = false;
95+
_switchingTo = null;
8896
}
8997
}
9098
}

0 commit comments

Comments
 (0)