fr.jeanf.universal.player 0.8.26 → 0.8.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -450,6 +450,28 @@ namespace jeanf.universalplayer
450
450
  if (!checkForDebugChangeState) return;
451
451
  _isDebugSTATIC = _isDebug;
452
452
  }
453
+ public static void PrepareVolumeProfile(FadeType fadeType)
454
+ {
455
+ if (staticPostProcessVolume == null)
456
+ {
457
+ if (_isDebugSTATIC) Debug.LogWarning("FadeMask: staticPostProcessVolume is null. Cannot prepare volume profile.");
458
+ return;
459
+ }
460
+
461
+ switch (fadeType)
462
+ {
463
+ case FadeType.Loading:
464
+ SetVolumeTo_FadeToBlack(); // Black fade
465
+ if (_isDebugSTATIC) Debug.Log("FadeMask: Volume profile prepared for Loading (black)");
466
+ break;
467
+ case FadeType.HeadInWall:
468
+ SetVolumeTo_FadeSaturation(); // Saturation fade
469
+ if (_isDebugSTATIC) Debug.Log("FadeMask: Volume profile prepared for HeadInWall (desaturated)");
470
+ break;
471
+ }
472
+
473
+ _currentFadeType = fadeType;
474
+ }
453
475
 
454
476
  public static void SwitchFadeState()
455
477
  {
@@ -484,23 +506,21 @@ namespace jeanf.universalplayer
484
506
  return;
485
507
  }
486
508
 
487
- // Always set up the volume profile for the requested fade type, even if we're not fading in
488
- // This ensures the profile is correct when we do fade in later
489
- switch (fadeType)
509
+ // Only set up the volume profile if we're changing fade types or fading in
510
+ if (_currentFadeType != fadeType || value)
490
511
  {
491
- case FadeType.Loading:
492
- SetVolumeTo_FadeToBlack(); // Black fade
493
- if (_isDebugSTATIC) Debug.Log("FadeMask: Volume profile set to Loading (black)");
494
- break;
495
- case FadeType.HeadInWall:
496
- SetVolumeTo_FadeSaturation(); // Saturation fade
497
- if (_isDebugSTATIC) Debug.Log("FadeMask: Volume profile set to HeadInWall (desaturated)");
498
- break;
512
+ switch (fadeType)
513
+ {
514
+ case FadeType.Loading:
515
+ SetVolumeTo_FadeToBlack(); // Black fade
516
+ break;
517
+ case FadeType.HeadInWall:
518
+ SetVolumeTo_FadeSaturation(); // Saturation fade
519
+ break;
520
+ }
521
+ _currentFadeType = fadeType;
499
522
  }
500
523
 
501
- // Update the current fade type
502
- _currentFadeType = fadeType;
503
-
504
524
  // Check if we're already transitioning to the same target state
505
525
  if (_isCurrentlyFading && _targetState == value)
506
526
  return;
@@ -1,6 +1,5 @@
1
1
  using jeanf.EventSystem;
2
2
  using UnityEngine;
3
- using UnityEngine.Serialization;
4
3
 
5
4
  namespace jeanf.universalplayer
6
5
  {
@@ -16,61 +15,62 @@ namespace jeanf.universalplayer
16
15
  [SerializeField] private LayerMask collisionLayer;
17
16
  [SerializeField] private float sphereCheckSize = .15f;
18
17
 
19
- [FormerlySerializedAs("_isHeadInWall")] [SerializeField] private bool fadeState = false;
20
- private bool _isHeadInWallLastValue = false;
18
+ [SerializeField] private bool _fadeState = false;
19
+ private bool _fadeStateLastValue = false;
21
20
 
22
21
  private static bool _isSceneLoading = true;
23
22
  private static bool _wasSceneLoadingLastFrame = true;
24
23
 
25
24
  private void FixedUpdate()
26
25
  {
27
- _isHeadInWallLastValue = fadeState;
26
+ _fadeStateLastValue = _fadeState;
27
+ bool wasLoadingLastFrame = _wasSceneLoadingLastFrame;
28
28
  _wasSceneLoadingLastFrame = _isSceneLoading;
29
29
 
30
30
  if (_isSceneLoading)
31
31
  {
32
- fadeState = true;
32
+ _fadeState = true;
33
33
  }
34
34
  else
35
35
  {
36
36
  if (isDebug) Debug.Log("NoPeeking - made it through the return");
37
37
  if (Physics.CheckSphere(transform.position, sphereCheckSize, collisionLayer, QueryTriggerInteraction.Ignore))
38
38
  {
39
- fadeState = true;
39
+ _fadeState = true;
40
40
  }
41
41
  else
42
42
  {
43
- fadeState = false;
43
+ _fadeState = false;
44
44
  }
45
45
  }
46
46
 
47
47
  // Check if loading state changed from true to false
48
- if (_wasSceneLoadingLastFrame && !_isSceneLoading)
48
+ if (wasLoadingLastFrame && !_isSceneLoading)
49
49
  {
50
- // Scene loading just finished - ensure we set up the correct fade type for head-in-wall detection
51
- if (isDebug) Debug.Log("Scene loading finished - setting up head-in-wall detection mode");
50
+ // Scene loading just finished - set up for head-in-wall detection
51
+ if (isDebug) Debug.Log("Scene loading finished - preparing head-in-wall detection mode");
52
52
 
53
- // Force a fade update with the correct type, even if the value hasn't changed
54
- FadeMask.FadeValue(fadeState, FadeMask.FadeType.HeadInWall);
55
- if (isDebug) Debug.Log($"Forced HeadInWall setup with value: {fadeState}");
56
- return; // Exit early to avoid duplicate fade calls
53
+ // Just prepare the volume profile without fading, let the normal logic handle the actual fade
54
+ FadeMask.PrepareVolumeProfile(FadeMask.FadeType.HeadInWall);
55
+
56
+ // Don't return early - let the normal logic below handle the fade state
57
57
  }
58
58
 
59
59
  // Normal state change detection
60
- if (fadeState == _isHeadInWallLastValue) return;
60
+ if (_fadeState == _fadeStateLastValue) return;
61
61
 
62
62
  // Determine fade type based on whether we're loading or detecting collision
63
63
  if (_isSceneLoading)
64
64
  {
65
65
  // Black fade for loading
66
- FadeMask.FadeValue(fadeState, FadeMask.FadeType.Loading);
67
- if (isDebug) Debug.Log($"Loading fade changed to: {fadeState}");
66
+ FadeMask.FadeValue(_fadeState, FadeMask.FadeType.Loading);
67
+ if (isDebug) Debug.Log($"Loading fade changed to: {_fadeState}");
68
68
  }
69
69
  else
70
70
  {
71
71
  // Gray fade for head-in-wall collision
72
- FadeMask.FadeValue(fadeState, FadeMask.FadeType.HeadInWall);
73
- if (isDebug) Debug.Log($"HeadInWall collision fade changed to: {fadeState}");
72
+ FadeMask.FadeValue(_fadeState, FadeMask.FadeType.HeadInWall);
73
+ if (isDebug) Debug.Log($"HeadInWall collision fade changed to: {_fadeState}");
74
74
  }
75
75
  }
76
76
 
@@ -86,15 +86,13 @@ namespace jeanf.universalplayer
86
86
  {
87
87
  _isSceneLoading = isLoading;
88
88
  }
89
-
90
89
  public static bool IsCurrentlyLoading()
91
90
  {
92
91
  return _isSceneLoading;
93
92
  }
94
-
95
- public bool IsHeadInWall()
93
+ public bool GetFadeState()
96
94
  {
97
- return fadeState;
95
+ return _fadeState;
98
96
  }
99
97
  }
100
98
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fr.jeanf.universal.player",
3
3
 
4
- "version": "0.8.26",
4
+ "version": "0.8.27",
5
5
 
6
6
  "displayName": "Universal Player",
7
7
  "description": "This package contains a universal player working in URP & HDRP for Mouse+Keyboard or VR",