com.puzzlescapegames.services 1.2.7 → 1.2.9

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.
package/README.md CHANGED
@@ -4,6 +4,7 @@ Common services.
4
4
  Install from npm by "com.puzzlescapegames.services".<br>
5
5
  >Required ```com.puzzlescapegames.extensions```<br>
6
6
  >Required ```com.puzzlescapegames.ioc_zenject```<br>
7
+ >Required ```com.puzzlescapegames.dotween```<br>
7
8
  >Required [UniTask]<br>
8
9
  ```
9
10
  "com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask",
@@ -6,7 +6,9 @@
6
6
  "GUID:9e5f34ba0cc07fc4184cb3bf9d5c4b7e",
7
7
  "GUID:0d8beb7f090555447a6cf5ce9e54dbb4",
8
8
  "GUID:f51ebe6a0ceec4240a699833d6309b23",
9
- "GUID:0c0c8357443d62a4c9e55fe39d3a3e51"
9
+ "GUID:0c0c8357443d62a4c9e55fe39d3a3e51",
10
+ "GUID:57c43d7b8262a5840908defee553447f",
11
+ "GUID:029c1c1b674aaae47a6841a0b89ad80e"
10
12
  ],
11
13
  "includePlatforms": [],
12
14
  "excludePlatforms": [],
@@ -0,0 +1,19 @@
1
+ using PuzzlescapeGames.Extensions;
2
+ using UnityEngine;
3
+
4
+ namespace PuzzlescapeGames.Services.UITransitionService
5
+ {
6
+ [ System.Serializable ]
7
+ public sealed class LoadingSettings
8
+ {
9
+ [ field: SerializeField ] public string UID { get; private set; } = "default";
10
+ [ field: Space ]
11
+ [ field: SerializeField ] public float InDuration { get; private set; } = 0.33f;
12
+ [ field: SerializeField ] public AnimationCurve InCurve { get; private set; } = AnimationCurveUtils.Default();
13
+ [ field: Space ]
14
+ [ field: SerializeField ] public float LoadingTime { get; private set; } = 1f;
15
+ [ field: Space ]
16
+ [ field: SerializeField ] public float OutDuration { get; private set; } = 0.16f;
17
+ [ field: SerializeField ] public AnimationCurve OutCurve { get; private set; } = AnimationCurveUtils.Default();
18
+ }
19
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 1cacd9054cf14fd8bbaf60a40b6b36b6
3
+ timeCreated: 1727240836
@@ -0,0 +1,12 @@
1
+ using System.Collections.Generic;
2
+ using UnityEngine;
3
+
4
+ namespace PuzzlescapeGames.Services.UITransitionService
5
+ {
6
+ [ System.Serializable ]
7
+ public sealed class TransitionSettings
8
+ {
9
+ [ field: SerializeField ] public List< LoadingSettings > LoadingSettings { get; private set; } = new();
10
+ [ field: SerializeField ] public UIInfinityBlank InfinityBlankPrefab { get; private set; }
11
+ }
12
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: fe151f236dd14fa3bd0ccfe9732e2bab
3
+ timeCreated: 1727237348
@@ -0,0 +1,73 @@
1
+ using Cysharp.Threading.Tasks;
2
+ using DG.Tweening;
3
+ using PuzzlescapeGames.Extensions;
4
+ using System;
5
+ using UnityEngine;
6
+
7
+ namespace PuzzlescapeGames.Services.UITransitionService
8
+ {
9
+ public sealed class UIInfinityBlank : MonoBehaviour
10
+ {
11
+ public event Action OnShowingChanged;
12
+ public event Action OnProcessCompleted;
13
+
14
+ [ field: SerializeField ] public CanvasGroup CanvasGroup { get; private set; }
15
+
16
+ public bool IsShowing
17
+ {
18
+ get => _isShowing;
19
+ set
20
+ {
21
+ _isShowing = value;
22
+ OnShowingChanged?.Invoke();
23
+ }
24
+ }
25
+ private bool _isShowing = false;
26
+
27
+ public bool IsInProcess
28
+ {
29
+ get => _isInProcess;
30
+ protected set
31
+ {
32
+ if (_isInProcess != value && value == false)
33
+ {
34
+ OnProcessCompleted?.Invoke();
35
+ }
36
+
37
+ _isInProcess = value;
38
+ }
39
+ }
40
+ private bool _isInProcess = false;
41
+
42
+ public async UniTask ShowAsync( float duration, AnimationCurve easing, Action callback = null )
43
+ {
44
+ IsInProcess = true;
45
+ CanvasGroup.alpha = 0f;
46
+ CanvasGroup.Enable( true, false );
47
+ IsShowing = true;
48
+
49
+ CanvasGroup.DOKill( true );
50
+
51
+ await CanvasGroup.DOFade( 1f, duration ).SetEase( easing ).ToUniTask();
52
+
53
+ IsInProcess = false;
54
+
55
+ callback?.Invoke();
56
+ }
57
+
58
+ public async UniTask HideAsync( float duration, AnimationCurve easing, Action callback = null )
59
+ {
60
+ IsInProcess = true;
61
+ CanvasGroup.Enable( false, false );
62
+ IsShowing = false;
63
+
64
+ CanvasGroup.DOKill( true );
65
+
66
+ await CanvasGroup.DOFade( 0f, duration ).SetEase( easing ).ToUniTask();
67
+
68
+ IsInProcess = false;
69
+
70
+ callback?.Invoke();
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 9aa6cd9fae0e4c3ebe9373c537035926
3
+ timeCreated: 1727237250
@@ -0,0 +1,73 @@
1
+ using Cysharp.Threading.Tasks;
2
+ using System;
3
+ using System.Linq;
4
+ using System.Threading;
5
+ using Object = UnityEngine.Object;
6
+
7
+ namespace PuzzlescapeGames.Services.UITransitionService
8
+ {
9
+ public sealed class UITransitionService
10
+ {
11
+ private UIInfinityBlank _blank;
12
+
13
+ private readonly TransitionSettings _settings;
14
+
15
+ public UITransitionService( TransitionSettings settings )
16
+ {
17
+ _settings = settings ?? throw new ArgumentNullException( nameof(settings) );
18
+ }
19
+
20
+ public async UniTask LoadThroughBlank(
21
+ int index = 0,
22
+ Action onShowed = null,
23
+ Action onLoaded = null,
24
+ Action onHided = null,
25
+ CancellationToken cancellationToken = default,
26
+ params UniTask[] tasks
27
+ )
28
+ {
29
+ await LoadThroughBlank( _settings.LoadingSettings[ index ], onShowed, onLoaded, onHided, cancellationToken, tasks );
30
+ }
31
+
32
+ public async UniTask LoadThroughBlank(
33
+ string uid,
34
+ Action onShowed = null,
35
+ Action onLoaded = null,
36
+ Action onHided = null,
37
+ CancellationToken cancellationToken = default,
38
+ params UniTask[] tasks
39
+ )
40
+ {
41
+ var loading = _settings.LoadingSettings.FirstOrDefault( ( x ) => string.Equals( x.UID, uid, StringComparison.InvariantCultureIgnoreCase ) );
42
+ await LoadThroughBlank( loading, onShowed, onLoaded, onHided, cancellationToken, tasks );
43
+ }
44
+
45
+ public async UniTask LoadThroughBlank(
46
+ LoadingSettings loading,
47
+ Action onShowed = null,
48
+ Action onLoaded = null,
49
+ Action onHided = null,
50
+ CancellationToken cancellationToken = default,
51
+ params UniTask[] tasks
52
+ )
53
+ {
54
+ if ( _blank == null )
55
+ {
56
+ _blank = Object.Instantiate( _settings.InfinityBlankPrefab );
57
+ Object.DontDestroyOnLoad( _blank );
58
+ }
59
+
60
+ await _blank.ShowAsync( loading.InDuration, loading.InCurve, onShowed );
61
+ if ( tasks.Length > 0 )
62
+ {
63
+ await UniTask.WhenAll( tasks );
64
+ }
65
+ else
66
+ {
67
+ await UniTask.WaitForSeconds( loading.LoadingTime, cancellationToken: cancellationToken );
68
+ }
69
+ onLoaded?.Invoke();
70
+ await _blank.HideAsync( loading.OutDuration, loading.OutCurve, onHided );
71
+ }
72
+ }
73
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 8d12b5364adb40e1b2b7b328139c2042
3
+ timeCreated: 1727173715
@@ -0,0 +1,17 @@
1
+ using UnityEngine;
2
+ using Zenject;
3
+
4
+ namespace PuzzlescapeGames.Services.UITransitionService
5
+ {
6
+ [ CreateAssetMenu( fileName = "UITransitionServiceInstaller", menuName = "Installers/UITransitionServiceInstaller" ) ]
7
+ public sealed class UITransitionServiceInstaller : ScriptableObjectInstaller< UITransitionServiceInstaller >
8
+ {
9
+ [ SerializeField ] private TransitionSettings _settings;
10
+
11
+ public override void InstallBindings()
12
+ {
13
+ Container.BindInstance( _settings );
14
+ Container.Bind< UITransitionService >().AsSingle();
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: a434e9a4dd88456db9ca2dcd3a356456
3
+ timeCreated: 1727173848
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: c24f2a0ac4cf9464cb38150ed18e9409
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name" : "com.puzzlescapegames.services",
3
3
  "displayName" : "Puzzlescape Games Services",
4
- "version" : "1.2.7",
4
+ "version" : "1.2.9",
5
5
  "author" : "Puzzlescape Games",
6
6
  "description" : "Common services.",
7
7
  "repository": {