fr.jeanf.universal.player 0.8.25 → 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,9 +506,9 @@ namespace jeanf.universalplayer
484
506
  return;
485
507
  }
486
508
 
487
- if (value)
509
+ // Only set up the volume profile if we're changing fade types or fading in
510
+ if (_currentFadeType != fadeType || value)
488
511
  {
489
- _currentFadeType = fadeType;
490
512
  switch (fadeType)
491
513
  {
492
514
  case FadeType.Loading:
@@ -496,15 +518,16 @@ namespace jeanf.universalplayer
496
518
  SetVolumeTo_FadeSaturation(); // Saturation fade
497
519
  break;
498
520
  }
499
-
500
- if (_isDebugSTATIC) Debug.Log($"FadeMask: Setting up {fadeType} fade");
521
+ _currentFadeType = fadeType;
501
522
  }
502
523
 
524
+ // Check if we're already transitioning to the same target state
503
525
  if (_isCurrentlyFading && _targetState == value)
504
526
  return;
505
527
 
506
528
  if (_isDebugSTATIC) Debug.Log($"FadeMask: Fading to {value} in {fadeTime}s with {fadeType} style");
507
529
 
530
+ // Cancel any existing fade
508
531
  if (_fadeHandle.IsActive())
509
532
  {
510
533
  _fadeHandle.Cancel();
@@ -15,46 +15,62 @@ namespace jeanf.universalplayer
15
15
  [SerializeField] private LayerMask collisionLayer;
16
16
  [SerializeField] private float sphereCheckSize = .15f;
17
17
 
18
- [SerializeField] private bool _isHeadInWall = false;
19
- private bool _isHeadInWallLastValue = false;
18
+ [SerializeField] private bool _fadeState = false;
19
+ private bool _fadeStateLastValue = false;
20
20
 
21
21
  private static bool _isSceneLoading = true;
22
+ private static bool _wasSceneLoadingLastFrame = true;
22
23
 
23
24
  private void FixedUpdate()
24
25
  {
25
- _isHeadInWallLastValue = _isHeadInWall;
26
+ _fadeStateLastValue = _fadeState;
27
+ bool wasLoadingLastFrame = _wasSceneLoadingLastFrame;
28
+ _wasSceneLoadingLastFrame = _isSceneLoading;
26
29
 
27
30
  if (_isSceneLoading)
28
31
  {
29
- _isHeadInWall = true;
32
+ _fadeState = true;
30
33
  }
31
34
  else
32
35
  {
33
36
  if (isDebug) Debug.Log("NoPeeking - made it through the return");
34
37
  if (Physics.CheckSphere(transform.position, sphereCheckSize, collisionLayer, QueryTriggerInteraction.Ignore))
35
38
  {
36
- _isHeadInWall = true;
39
+ _fadeState = true;
37
40
  }
38
41
  else
39
42
  {
40
- _isHeadInWall = false;
43
+ _fadeState = false;
41
44
  }
42
45
  }
43
46
 
44
- if (_isHeadInWall == _isHeadInWallLastValue) return;
47
+ // Check if loading state changed from true to false
48
+ if (wasLoadingLastFrame && !_isSceneLoading)
49
+ {
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
+
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
+ }
58
+
59
+ // Normal state change detection
60
+ if (_fadeState == _fadeStateLastValue) return;
45
61
 
46
62
  // Determine fade type based on whether we're loading or detecting collision
47
63
  if (_isSceneLoading)
48
64
  {
49
65
  // Black fade for loading
50
- FadeMask.FadeValue(_isHeadInWall, FadeMask.FadeType.Loading);
51
- if (isDebug) Debug.Log($"Loading fade changed to: {_isHeadInWall}");
66
+ FadeMask.FadeValue(_fadeState, FadeMask.FadeType.Loading);
67
+ if (isDebug) Debug.Log($"Loading fade changed to: {_fadeState}");
52
68
  }
53
69
  else
54
70
  {
55
71
  // Gray fade for head-in-wall collision
56
- FadeMask.FadeValue(_isHeadInWall, FadeMask.FadeType.HeadInWall);
57
- if (isDebug) Debug.Log($"HeadInWall collision fade changed to: {_isHeadInWall}");
72
+ FadeMask.FadeValue(_fadeState, FadeMask.FadeType.HeadInWall);
73
+ if (isDebug) Debug.Log($"HeadInWall collision fade changed to: {_fadeState}");
58
74
  }
59
75
  }
60
76
 
@@ -70,21 +86,13 @@ namespace jeanf.universalplayer
70
86
  {
71
87
  _isSceneLoading = isLoading;
72
88
  }
73
-
74
- /// <summary>
75
- /// Gets the current loading state
76
- /// </summary>
77
89
  public static bool IsCurrentlyLoading()
78
90
  {
79
91
  return _isSceneLoading;
80
92
  }
81
-
82
- /// <summary>
83
- /// Gets the current head-in-wall state (useful for debugging)
84
- /// </summary>
85
- public bool IsHeadInWall()
93
+ public bool GetFadeState()
86
94
  {
87
- return _isHeadInWall;
95
+ return _fadeState;
88
96
  }
89
97
  }
90
98
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fr.jeanf.universal.player",
3
3
 
4
- "version": "0.8.25",
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",