com.soosvet_games.common_tools 1.0.8 → 1.1.0
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.
|
@@ -6,32 +6,53 @@ namespace SoosvetGames.CommonTools.Extensions.Editor
|
|
|
6
6
|
[ InitializeOnLoad ]
|
|
7
7
|
internal static class HierarchyActivationTool
|
|
8
8
|
{
|
|
9
|
-
static HierarchyActivationTool()
|
|
9
|
+
static HierarchyActivationTool()
|
|
10
|
+
{
|
|
11
|
+
#if UNITY_6000_3_OR_NEWER
|
|
12
|
+
EditorApplication.hierarchyWindowItemByEntityIdOnGUI += HierarchyWindowOnGui;
|
|
13
|
+
#else
|
|
14
|
+
EditorApplication.hierarchyWindowItemOnGUI += HierarchyWindowOnGui;
|
|
15
|
+
#endif
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
#if UNITY_6000_3_OR_NEWER
|
|
19
|
+
|
|
20
|
+
private static void HierarchyWindowOnGui(EntityId entityId, Rect selectionRect)
|
|
21
|
+
{
|
|
22
|
+
var obj = EditorUtility.EntityIdToObject(entityId) as GameObject;
|
|
10
23
|
|
|
11
|
-
|
|
24
|
+
DrawToggle(obj, selectionRect);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#else
|
|
28
|
+
|
|
29
|
+
private static void HierarchyWindowOnGui( int instanceId, Rect selectionRect )
|
|
12
30
|
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
var obj = EditorUtility.InstanceIDToObject( instanceId ) as GameObject;
|
|
32
|
+
|
|
33
|
+
DrawToggle( obj, selectionRect );
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
private static void DrawToggle( GameObject obj, Rect selectionRect )
|
|
39
|
+
{
|
|
40
|
+
if ( obj == null )
|
|
41
|
+
return;
|
|
42
|
+
|
|
43
|
+
var rect = new Rect( selectionRect ) { x = 35, width = 18 };
|
|
44
|
+
|
|
45
|
+
bool previousValue = obj.activeSelf;
|
|
46
|
+
bool newValue = GUI.Toggle( rect, previousValue, string.Empty );
|
|
47
|
+
|
|
48
|
+
if ( newValue == previousValue )
|
|
49
|
+
return;
|
|
50
|
+
|
|
51
|
+
Undo.RecordObject( obj, $"Set Active {obj.name}" );
|
|
52
|
+
|
|
53
|
+
obj.SetActive( newValue );
|
|
54
|
+
|
|
55
|
+
EditorUtility.SetDirty( obj );
|
|
35
56
|
}
|
|
36
57
|
}
|
|
37
58
|
}
|
|
@@ -22,61 +22,50 @@ namespace SoosvetGames.CommonTools.Services.AudioService
|
|
|
22
22
|
}
|
|
23
23
|
private UnityEngine.AudioSource _source;
|
|
24
24
|
|
|
25
|
-
public bool IsPlaying
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
_isPlaying = value;
|
|
31
|
-
PlayingChangedHandler();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
private bool _isPlaying = false;
|
|
35
|
-
|
|
36
|
-
public bool isLoop { get; private set; } = false;
|
|
25
|
+
public bool IsPlaying => Source.isPlaying || _isPaused;
|
|
26
|
+
public bool IsLoop => Source.loop;
|
|
27
|
+
|
|
28
|
+
private bool _isPaused;
|
|
29
|
+
private int _playVersion;
|
|
37
30
|
|
|
38
31
|
public void PlayLoop( AudioClip clip )
|
|
39
32
|
{
|
|
40
|
-
|
|
41
|
-
Source.clip = clip;
|
|
42
|
-
Loop( true );
|
|
33
|
+
Prepare( clip, true );
|
|
43
34
|
Source.Play();
|
|
44
35
|
}
|
|
45
36
|
|
|
46
37
|
public void PlayOnce( AudioClip clip )
|
|
47
38
|
{
|
|
48
|
-
|
|
39
|
+
Prepare( clip, false );
|
|
40
|
+
|
|
41
|
+
var playVersion = ++_playVersion;
|
|
49
42
|
|
|
50
|
-
|
|
51
|
-
Source.PlayOneShot( clip );
|
|
43
|
+
Source.Play();
|
|
52
44
|
|
|
53
|
-
|
|
45
|
+
WaitForComplete( playVersion ).Forget();
|
|
54
46
|
}
|
|
55
47
|
|
|
56
48
|
public void Stop()
|
|
57
49
|
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
public void Rewind()
|
|
63
|
-
{
|
|
64
|
-
Source.time = 0;
|
|
50
|
+
++_playVersion;
|
|
51
|
+
|
|
52
|
+
_isPaused = false;
|
|
53
|
+
|
|
65
54
|
Source.Stop();
|
|
66
|
-
|
|
55
|
+
Source.clip = null;
|
|
67
56
|
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
return DOTween.To( () => Source.volume, ( x ) => Source.volume = x, target, duration );
|
|
57
|
+
DespawnIt();
|
|
71
58
|
}
|
|
72
59
|
|
|
73
|
-
public void
|
|
60
|
+
public void Rewind()
|
|
74
61
|
{
|
|
75
|
-
Source.
|
|
62
|
+
Source.time = 0f;
|
|
76
63
|
}
|
|
77
64
|
|
|
78
65
|
public void Pause( bool trigger )
|
|
79
66
|
{
|
|
67
|
+
_isPaused = trigger;
|
|
68
|
+
|
|
80
69
|
if ( trigger )
|
|
81
70
|
{
|
|
82
71
|
Source.Pause();
|
|
@@ -86,32 +75,44 @@ namespace SoosvetGames.CommonTools.Services.AudioService
|
|
|
86
75
|
Source.UnPause();
|
|
87
76
|
}
|
|
88
77
|
}
|
|
89
|
-
|
|
78
|
+
|
|
79
|
+
public void Mute( bool trigger )
|
|
80
|
+
{
|
|
81
|
+
Source.mute = trigger;
|
|
82
|
+
}
|
|
83
|
+
|
|
90
84
|
public void Loop( bool trigger )
|
|
91
85
|
{
|
|
92
|
-
isLoop = trigger;
|
|
93
86
|
Source.loop = trigger;
|
|
94
87
|
}
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
|
|
89
|
+
public Tween DoVolume( float target, float duration )
|
|
97
90
|
{
|
|
98
|
-
|
|
91
|
+
return DOTween.To( () => Source.volume, x => Source.volume = x, target, duration );
|
|
99
92
|
}
|
|
100
|
-
|
|
101
|
-
private
|
|
93
|
+
|
|
94
|
+
private void Prepare( AudioClip clip, bool loop )
|
|
102
95
|
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
++_playVersion;
|
|
97
|
+
|
|
98
|
+
_isPaused = false;
|
|
99
|
+
|
|
100
|
+
Source.Stop();
|
|
101
|
+
Source.clip = clip;
|
|
102
|
+
Source.loop = loop;
|
|
107
103
|
}
|
|
108
104
|
|
|
109
|
-
private
|
|
105
|
+
private async UniTask WaitForComplete( int playVersion )
|
|
110
106
|
{
|
|
111
|
-
|
|
107
|
+
await UniTask.WaitUntil( () => playVersion != _playVersion || !IsPlaying, cancellationToken: destroyCancellationToken );
|
|
108
|
+
|
|
109
|
+
if ( playVersion != _playVersion )
|
|
112
110
|
{
|
|
113
|
-
|
|
111
|
+
return;
|
|
114
112
|
}
|
|
113
|
+
|
|
114
|
+
Source.clip = null;
|
|
115
|
+
DespawnIt();
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
}
|