Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Assets/Environment/MainCamera.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Settings;
using System;
using UnityEngine;
using Utils;
using UnityEngine.Rendering.Universal;
using UnityEngine.Serialization;
using View.Overlay;
using View.Settings;

namespace Environment {
public class MainCamera : MonoBehaviour {
[FormerlySerializedAs("_settings")] [Inject] [SerializeField] private OverlayChannel _overlay;
private Camera _camera;
private Camera _overlayCamera;

private void Awake() {
_camera = GetComponent<Camera>();
_overlay.CameraChanged += HandleCameraChanged;
}

private void OnDestroy() {
_overlay.CameraChanged -= HandleCameraChanged;
}

private void HandleCameraChanged(OverlayCamera overlayCamera) {
var data = _camera.GetUniversalAdditionalCameraData();
if (_overlayCamera != null) {
data.cameraStack.Remove(_overlayCamera);
}
if (overlayCamera != null) {
_overlayCamera = overlayCamera.NativeCamera;
data.cameraStack.Add(_overlayCamera);
}
}

private void Start() { }
}
}
3 changes: 3 additions & 0 deletions Assets/Environment/MainCamera.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Assets/Environment/Materials/BoxSDF.mat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Assets/Environment/Models/Folder.fbx
Git LFS file not shown
8 changes: 4 additions & 4 deletions Assets/Environment/Models/Folder.fbx.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 17 additions & 7 deletions Assets/Environment/Prefabs/Doc.prefab

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 25 additions & 8 deletions Assets/Environment/Prefabs/Tape.prefab

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions Assets/Environment/Shaders/BoxSDF.shader
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ Shader "GUI/BoxSDF"
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_PaintTex ("Paint Texture", 2D) = "white" {}
_Radius ("Radius", Float) = 0.3
_StrokeWidth ("Stroke Width", Float) = 0.1
_Smoothness ("Smoothness", Float) = 0.01
_Test ("Test", Vector) = (0, 0, 0, 0)

[HideInInspector] _StencilComp ("Stencil Comparison", Float) = 8
[HideInInspector] _Stencil ("Stencil ID", Float) = 0
Expand Down Expand Up @@ -62,6 +64,7 @@ Shader "GUI/BoxSDF"
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 params : TEXCOORD1;
float4 params2 : TEXCOORD2;
UNITY_VERTEX_INPUT_INSTANCE_ID
};

Expand All @@ -72,6 +75,7 @@ Shader "GUI/BoxSDF"
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
float4 params : TEXCOORD2;
float4 params2 : TEXCOORD3;
UNITY_VERTEX_OUTPUT_STEREO
};

Expand All @@ -82,6 +86,7 @@ Shader "GUI/BoxSDF"
float _StrokeWidth;
float _Smoothness;
float4 _ClipRect;
float4 _Test;

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

output.texcoord = input.texcoord;
output.params = input.params;
output.params2 = input.params2;
output.color = input.color;
return output;
}
Expand Down Expand Up @@ -137,6 +143,13 @@ Shader "GUI/BoxSDF"
distance
);

float paint = tex2D(_PaintTex, (uv * size + input.params2.xy) * 0.01).b;
// color.rgb += lerp(input.params2.z, input.params2.w, paint);
paint -= _Test.x;
paint *= _Test.y;
paint *= input.params2.z;
color.rgb += paint;

#ifdef UNITY_UI_CLIP_RECT
color.a *= get2DClipping(input.worldPosition.xy, _ClipRect);
#endif
Expand Down
20 changes: 14 additions & 6 deletions Assets/Framework/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ public class GameManager : MonoBehaviour {
[Inject] public AudioManager Audio;

private GameMode _currentMode;
private bool _isSwitching;
private GameMode _switchingTo;

private bool ISSwitching => !ReferenceEquals(_switchingTo, null);

public void RequestMode(GameMode mode) {
if (_switchingTo == mode || _currentMode == mode) {
return;
}

StartCoroutine(SwitchMode(mode));
}

Expand Down Expand Up @@ -70,21 +76,23 @@ private IEnumerator Reload() {
#endif

private IEnumerator SwitchMode(GameMode mode) {
yield return new WaitUntil(() => !_isSwitching);

if (_currentMode == mode) {
if (_switchingTo == mode || _currentMode == mode) {
yield break;
}

_isSwitching = true;
if (ISSwitching) {
yield return new WaitUntil(() => !ISSwitching);
}

_switchingTo = mode;
if (!ReferenceEquals(_currentMode, null)) {
yield return _currentMode.OnEnd();
}

_currentMode = mode;
yield return _currentMode.OnStart();

_isSwitching = false;
_switchingTo = null;
}
}
}
Loading