Skip to content

Commit f0e8ac3

Browse files
authored
Merge pull request #4 from Machillka/develop
Develop
2 parents c2faf46 + 2326183 commit f0e8ac3

11 files changed

Lines changed: 454 additions & 71 deletions

File tree

.vscode/settings.json

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
11
{
2-
"files.exclude": {
3-
"**/.DS_Store": true,
4-
"**/.git": true,
5-
"**/.vs": true,
6-
"**/.gitmodules": true,
7-
"**/.vsconfig": true,
8-
"**/*.booproj": true,
9-
"**/*.pidb": true,
10-
"**/*.suo": true,
11-
"**/*.user": true,
12-
"**/*.userprefs": true,
13-
"**/*.unityproj": true,
14-
"**/*.dll": true,
15-
"**/*.exe": true,
16-
"**/*.pdf": true,
17-
"**/*.mid": true,
18-
"**/*.midi": true,
19-
"**/*.wav": true,
20-
"**/*.gif": true,
21-
"**/*.ico": true,
22-
"**/*.jpg": true,
23-
"**/*.jpeg": true,
24-
"**/*.png": true,
25-
"**/*.psd": true,
26-
"**/*.tga": true,
27-
"**/*.tif": true,
28-
"**/*.tiff": true,
29-
"**/*.3ds": true,
30-
"**/*.3DS": true,
31-
"**/*.fbx": true,
32-
"**/*.FBX": true,
33-
"**/*.lxo": true,
34-
"**/*.LXO": true,
35-
"**/*.ma": true,
36-
"**/*.MA": true,
37-
"**/*.obj": true,
38-
"**/*.OBJ": true,
39-
"**/*.asset": true,
40-
"**/*.cubemap": true,
41-
"**/*.flare": true,
42-
"**/*.mat": true,
43-
"**/*.meta": true,
44-
"**/*.prefab": true,
45-
"**/*.unity": true,
46-
"build/": true,
47-
"Build/": true,
48-
"Library/": true,
49-
"library/": true,
50-
"obj/": true,
51-
"Obj/": true,
52-
"Logs/": true,
53-
"logs/": true,
54-
"ProjectSettings/": true,
55-
"UserSettings/": true,
56-
"temp/": true,
57-
"Temp/": true
58-
},
59-
"files.associations": {
60-
"*.asset": "yaml",
61-
"*.meta": "yaml",
62-
"*.prefab": "yaml",
63-
"*.unity": "yaml"
64-
},
65-
"explorer.fileNesting.enabled": true,
66-
"explorer.fileNesting.patterns": {
67-
"*.sln": "*.csproj"
68-
},
69-
"dotnet.defaultSolution": "Framework.sln",
70-
"git.ignoreLimitWarning": true
71-
}
2+
"files.exclude": {
3+
"**/.DS_Store": true,
4+
"**/.git": true,
5+
"**/.vs": true,
6+
"**/.gitmodules": true,
7+
"**/.vsconfig": true,
8+
"**/*.booproj": true,
9+
"**/*.pidb": true,
10+
"**/*.suo": true,
11+
"**/*.user": true,
12+
"**/*.userprefs": true,
13+
"**/*.unityproj": true,
14+
"**/*.dll": true,
15+
"**/*.exe": true,
16+
"**/*.pdf": true,
17+
"**/*.mid": true,
18+
"**/*.midi": true,
19+
"**/*.wav": true,
20+
"**/*.gif": true,
21+
"**/*.ico": true,
22+
"**/*.jpg": true,
23+
"**/*.jpeg": true,
24+
"**/*.png": true,
25+
"**/*.psd": true,
26+
"**/*.tga": true,
27+
"**/*.tif": true,
28+
"**/*.tiff": true,
29+
"**/*.3ds": true,
30+
"**/*.3DS": true,
31+
"**/*.fbx": true,
32+
"**/*.FBX": true,
33+
"**/*.lxo": true,
34+
"**/*.LXO": true,
35+
"**/*.ma": true,
36+
"**/*.MA": true,
37+
"**/*.obj": true,
38+
"**/*.OBJ": true,
39+
"**/*.asset": true,
40+
"**/*.cubemap": true,
41+
"**/*.flare": true,
42+
"**/*.mat": true,
43+
"**/*.meta": true,
44+
"**/*.prefab": true,
45+
"**/*.unity": true,
46+
"build/": true,
47+
"Build/": true,
48+
"Library/": true,
49+
"library/": true,
50+
"obj/": true,
51+
"Obj/": true,
52+
"Logs/": true,
53+
"logs/": true,
54+
"ProjectSettings/": true,
55+
"UserSettings/": true,
56+
"temp/": true,
57+
"Temp/": true
58+
},
59+
"files.associations": {
60+
"*.asset": "yaml",
61+
"*.meta": "yaml",
62+
"*.prefab": "yaml",
63+
"*.unity": "yaml"
64+
},
65+
"explorer.fileNesting.enabled": true,
66+
"explorer.fileNesting.patterns": {
67+
"*.sln": "*.csproj"
68+
},
69+
"dotnet.defaultSolution": "Unity-Framework.sln",
70+
"git.ignoreLimitWarning": true
71+
}

Assets/Framework/Sample/Scenes/SampleScene.unity

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ GameObject:
130130
- component: {fileID: 365617369}
131131
- component: {fileID: 365617368}
132132
m_Layer: 0
133-
m_Name: GameObject
133+
m_Name: Bootstrap
134134
m_TagString: Untagged
135135
m_Icon: {fileID: 0}
136136
m_NavMeshLayer: 0

Assets/Framework/Scripts/Utilities/Audio Manager.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
using System.Collections.Generic;
2+
using UnityEngine;
3+
4+
namespace Framework.Utilities.AudioManager
5+
{
6+
[CreateAssetMenu(fileName = "AudioCatalog", menuName = "Framework/Audio/Audio Catalog")]
7+
public class AudioCatalogSO : ScriptableObject
8+
{
9+
public List<SoundEntry> entries = new();
10+
public Dictionary<string, SoundEntry> entriesDict = new();
11+
12+
// NOTE: 在编辑器中保持同步,以及统计数量一样不代表内容一致
13+
private void EnsureMap()
14+
{
15+
if (entries.Count != entriesDict.Count)
16+
{
17+
entriesDict.Clear();
18+
foreach (var e in entries)
19+
{
20+
if (!entriesDict.ContainsKey(e.id))
21+
{
22+
entriesDict.Add(e.id, e);
23+
}
24+
}
25+
}
26+
}
27+
28+
public SoundEntry GetSoundEntry(string id)
29+
{
30+
EnsureMap();
31+
return entriesDict.TryGetValue(id, out var entry) ? entry : null;
32+
}
33+
34+
public AudioClip GetAudioClip(string id)
35+
{
36+
EnsureMap();
37+
return entriesDict.TryGetValue(id, out var entry) ? entry.clip : null;
38+
}
39+
40+
#if UNITY_EDITOR
41+
public void EditorRebuild()
42+
{
43+
entriesDict.Clear();
44+
EnsureMap();
45+
UnityEditor.EditorUtility.SetDirty(this);
46+
}
47+
#endif
48+
}
49+
50+
[System.Serializable]
51+
public class SoundEntry
52+
{
53+
public string id;
54+
public AudioClip clip;
55+
[Range(0f, 1f)] public float defaultVolume = 1f;
56+
[Range(0.5f, 2f)] public float defaultPitch = 1f;
57+
public bool spatial = false;
58+
public bool loop = false;
59+
}
60+
}

Assets/Framework/Scripts/Utilities/Audio Manager/AudioEntry.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using UnityEngine;
2+
using System;
3+
4+
namespace Framework.Utilities.AudioManager
5+
{
6+
public class AudioHandle
7+
{
8+
AudioSource _src;
9+
Action<AudioSource> _release;
10+
11+
internal AudioHandle(AudioSource src, Action<AudioSource> release)
12+
{
13+
_src = src;
14+
_release = release;
15+
}
16+
17+
public bool IsPlaying => _src != null && _src.isPlaying;
18+
19+
// 关闭音效,并且调用回调函数
20+
public void Stop()
21+
{
22+
if (_src == null) return;
23+
_src.Stop();
24+
_release?.Invoke(_src);
25+
_src = null;
26+
_release = null;
27+
}
28+
29+
// Internal: used by manager to return when finished
30+
internal void ReturnIfFinished()
31+
{
32+
if (_src == null) return;
33+
if (!_src.isPlaying)
34+
{
35+
_release?.Invoke(_src);
36+
_src = null;
37+
_release = null;
38+
}
39+
}
40+
}
41+
42+
}

Assets/Framework/Scripts/Utilities/Audio Manager/AudioHandler.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)