Skip to content

Commit 757bfeb

Browse files
committed
更新框架
1 parent 75a3ee3 commit 757bfeb

File tree

381 files changed

+6933
-3022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

381 files changed

+6933
-3022
lines changed

Assets/Script/Core/Audio/AudioManager/AudioAsset.cs

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ public enum AudioSourceType
1919
}
2020
public class AudioAsset
2121
{
22+
[NotJsonSerialized]
2223
public AudioSource audioSource;
2324
public AudioSourceType sourceType;
2425
public string flag = "";
25-
public string assetName = "";
26+
private string assetName = "";
2627
/// <summary>
2728
/// music,记录channel
2829
/// </summary>
@@ -92,30 +93,57 @@ public AudioPlayState PlayState
9293

9394
}
9495

95-
96+
public string AssetName {
97+
get
98+
{
99+
if(audioSource!=null&& audioSource.clip != null)
100+
{
101+
if (string.IsNullOrEmpty(assetName))
102+
{
103+
assetName = audioSource.clip.name;
104+
}
105+
}
106+
return assetName;
107+
}
108+
set
109+
{
110+
assetName = value;
111+
}
112+
}
96113

97114
public void SetPlayState(AudioPlayState state)
98115
{
99116
playState = state;
100117
}
118+
private bool isCallPreStop;
101119
/// <summary>
102120
/// 检查音频是否播放完成
103121
/// </summary>
104122
public void CheckState()
105123
{
106124
if (playState == AudioPlayState.Stop)
107125
return;
126+
//Debug.Log("audioSource.time:" + audioSource.time + " clip.lenth:" + audioSource.clip.length);
127+
if (audioSource.clip.length>1&& audioSource.time >= (audioSource.clip.length - 1)&& !isCallPreStop)
128+
{
129+
isCallPreStop = true;
130+
if (AudioPlayManager.OnMusicPreStopCallBack != null)
131+
AudioPlayManager.OnMusicPreStopCallBack(AssetName, musicChannel, flag);
132+
}
108133
if (audioSource == null || (!audioSource.isPlaying && playState != AudioPlayState.Pause))
109134
{
110135
Stop();
111136
}
112137

138+
113139
}
114140

115141
public void Play(float delay = 0f)
116142
{
117143
if (audioSource != null && audioSource.clip != null)
118144
{
145+
isCallPreStop = false;
146+
audioSource.time = 0;
119147
audioSource.PlayDelayed(delay);
120148
playState = AudioPlayState.Playing;
121149

@@ -137,13 +165,20 @@ public void Stop()
137165

138166
if(sourceType== AudioSourceType.Music)
139167
{
168+
if(!isCallPreStop)
169+
{
170+
isCallPreStop = true;
171+
if (AudioPlayManager.OnMusicPreStopCallBack != null)
172+
AudioPlayManager.OnMusicPreStopCallBack(AssetName, musicChannel, flag);
173+
}
174+
140175
if (AudioPlayManager.OnMusicStopCallBack != null)
141-
AudioPlayManager.OnMusicStopCallBack(assetName, musicChannel, flag);
176+
AudioPlayManager.OnMusicStopCallBack(AssetName, musicChannel, flag);
142177
}
143178
else
144179
{
145180
if (AudioPlayManager.OnSFXStopCallBack != null)
146-
AudioPlayManager.OnSFXStopCallBack(assetName, flag);
181+
AudioPlayManager.OnSFXStopCallBack(AssetName, flag);
147182
}
148183
}
149184

@@ -152,7 +187,7 @@ public void Stop()
152187
/// </summary>
153188
public void ResetData()
154189
{
155-
assetName = "";
190+
AssetName = "";
156191
audioSource.pitch = 1;
157192
flag = "";
158193
}

Assets/Script/Core/Audio/AudioManager/AudioGroupSystem/RandomLoopMusicData.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ public RandomLoopMusicData(MusicRandomLoopData configData)
1818
flag = GetHashCode().ToString();
1919
AudioPlayManager.OnMusicStopCallBack += OnMusicPlayComplete;
2020
}
21-
21+
/// <summary>
22+
/// music播放完成,
23+
/// </summary>
24+
/// <param name="name"></param>
25+
/// <param name="channal"></param>
26+
/// <param name="flag">flag标识自生实例</param>
2227
private void OnMusicPlayComplete(string name, int channal, string flag)
2328
{
2429
if (this.flag == flag)

Assets/Script/Core/Audio/AudioManager/AudioPlayManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public class AudioPlayManager : MonoBehaviour
1313
/// 音乐播放完成 回调(参数 :资源名,channel,flag(标识:用于在多个相同音频名称时分辨))
1414
/// </summary>
1515
public static CallBack<string, int, string> OnMusicStopCallBack;
16+
/// <summary>
17+
/// 音乐播放将要完成 回调,提前1秒回调,当clip时长不足1秒则在OnMusicStopCallBack前回调(参数 :资源名,channel,flag(标识:用于在多个相同音频名称时分辨))
18+
/// </summary>
19+
public static CallBack<string, int, string> OnMusicPreStopCallBack;
1620

1721
/// <summary>
1822
/// SFX播放完成 回调(参数 :资源名,flag(标识:用于在多个相同音频名称时分辨))

Assets/Script/Core/Audio/AudioManager/AudioPlayerBase.cs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void UnloadClip(AudioAsset asset)
9090
{
9191
if (asset.audioSource.clip != null)
9292
{
93-
string name = asset.assetName;
93+
string name = asset.AssetName;
9494
asset.audioSource.clip = null;
9595
ResourceManager.DestoryAssetsCounter(name);
9696
}
@@ -106,8 +106,8 @@ protected void PlayClip(AudioAsset au, string audioName, bool isLoop = true, flo
106106
//if (au.PlayState == AudioPlayState.Playing)
107107
// au.Stop();
108108
UnloadClip(au);
109-
au.assetName = audioName;
110-
AudioClip ac = GetAudioClip(au.assetName);
109+
au.AssetName = audioName;
110+
AudioClip ac = GetAudioClip(au.AssetName);
111111
au.audioSource.clip = ac;
112112
au.audioSource.loop = isLoop;
113113
au.audioSource.pitch = pitch;
@@ -119,8 +119,9 @@ protected void PlayClip(AudioAsset au, string audioName, bool isLoop = true, flo
119119
protected void PlayMusicControl(AudioAsset au, string audioName, bool isLoop = true, float volumeScale = 1, float delay = 0f, float fadeTime = 0.5f, string flag = "")
120120
{
121121

122-
if (au.assetName == audioName)
122+
if (au.AssetName == audioName)
123123
{
124+
au.audioSource.loop = isLoop;
124125
if (au.PlayState != AudioPlayState.Playing)
125126
{
126127
AddFade(au, VolumeFadeType.FadeIn, fadeTime, delay,flag, null, null);
@@ -261,6 +262,7 @@ public void AddFade(AudioAsset au, VolumeFadeType fadeType, float fadeTime, floa
261262
data = new VolumeFadeData();
262263
}
263264
fadeData.Add(au, data);
265+
//data.tempVolume = 0;
264266
//Debug.Log("Add");
265267
}
266268
if (data.fadeOutCompleteCallBack != null)
@@ -283,22 +285,22 @@ public void AddFade(AudioAsset au, VolumeFadeType fadeType, float fadeTime, floa
283285
switch (data.fadeType)
284286
{
285287
case VolumeFadeType.FadeIn:
286-
// data.au.Volume = 0;
288+
data.au.Volume = 0;
287289
data.fadeState = VolumeFadeStateType.FadeIn;
288290
break;
289291
case VolumeFadeType.FadeOut:
290292
data.fadeState = VolumeFadeStateType.FadeOut;
291-
// data.au.ResetVolume();
293+
data.au.ResetVolume();
292294
break;
293295
case VolumeFadeType.FadeOut2In:
294296
data.fadeState = VolumeFadeStateType.FadeOut;
295-
// data.au.ResetVolume();
297+
data.au.ResetVolume();
296298
break;
297299
}
298300
data.tempVolume = data.au.Volume;
299301
data.delayTime = delay;
300302
//Debug.Log("AddFade:"+ data.fadeType);
301-
303+
//Debug.Log("Add AddFade:" + JsonUtils.ToJson(data));
302304
}
303305

304306
/// <summary>
@@ -309,16 +311,17 @@ public void AddFade(AudioAsset au, VolumeFadeType fadeType, float fadeTime, floa
309311
private bool FadeIn(VolumeFadeData data)
310312
{
311313
//Debug.Log("FadeIn");
312-
if (string.IsNullOrEmpty(data.au.assetName))
314+
if (data.au == null || data.au.audioSource == null || data.au.audioSource.clip == null)
313315
{
314316
data.au.ResetVolume();
317+
data.tempVolume = 1;
315318
return true;
316319
}
317320
float oldVolume = data.tempVolume;
318-
321+
//Debug.Log("FadeIn:data.au.Volume " + data.au.Volume + " dowm :" + oldVolume);
319322
float speed = data.au.GetMaxRealVolume() / data.fadeTime * 2f;
320323
oldVolume = oldVolume + speed * Time.unscaledDeltaTime;
321-
//Debug.Log("FadeIn:data.au.Volume " + data.au.Volume + " dowm :" + oldVolume);
324+
322325
data.au.Volume = oldVolume;
323326
data.tempVolume = oldVolume;
324327

@@ -334,18 +337,19 @@ private bool FadeIn(VolumeFadeData data)
334337

335338
public bool FadeOut(VolumeFadeData data)
336339
{
337-
//Debug.Log("FadeOut");
338-
if (string.IsNullOrEmpty(data.au.assetName))
340+
//Debug.Log("FadeOut:"+ data.au.AssetName);
341+
if (data.au==null||data.au.audioSource==null||data.au.audioSource.clip==null)
339342
{
340343
data.au.Volume = 0;
344+
data.tempVolume = 0;
341345
return true;
342346
}
343347

344348
float oldVolume = data.tempVolume;
345349

346350
float speed = data.au.GetMaxRealVolume() / data.fadeTime;
347351
oldVolume = oldVolume - speed * Time.unscaledDeltaTime;
348-
//Debug.Log("FadeOut:data.au.Volume " + data.au.Volume+" dowm :"+ oldVolume);
352+
//Debug.Log("FadeOut:data.au.Volume " + data.au.Volume + " dowm :" + oldVolume);
349353
//Debug.Log(" FadeOut fade State :" + data.fadeState);
350354
data.au.Volume = oldVolume;
351355
data.tempVolume = oldVolume;
@@ -362,7 +366,7 @@ public bool FadeOut(VolumeFadeData data)
362366

363367
public bool FadeOut2In(VolumeFadeData data)
364368
{
365-
//Debug.Log(" FadeOut2In :" + data.fadeTime);
369+
//Debug.Log("FadeOut2In:data.au.Volume " + data.au.Volume + " dowm :" + data.tempVolume+ " data.fadeState:"+ data.fadeState+ " data.fadeType:" + data.fadeType+" :"+JsonUtils.ToJson(data));
366370

367371
if (data.fadeState == VolumeFadeStateType.FadeOut)
368372
{
@@ -378,6 +382,7 @@ public bool FadeOut2In(VolumeFadeData data)
378382
else if (data.fadeState == VolumeFadeStateType.Delay)
379383
{
380384
data.delayTime -= Time.unscaledDeltaTime;
385+
//Debug.Log("Delay : data.delayTime:" + data.delayTime + " Time.unscaledDeltaTime:" + Time.unscaledDeltaTime);
381386
if (data.delayTime <= 0)
382387
{
383388
data.fadeState = VolumeFadeStateType.FadeIn;

Assets/Script/Core/Audio/AudioManager/Editor/AudioManagerWindow.cs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private void A2DPlayerGUI()
8181
});
8282

8383
}
84-
84+
private bool changedTime = false;
8585
private void ShowAudioAssetGUI(AudioAsset au,bool isShowAudioSource)
8686
{
8787
Color color = Color.white;
@@ -99,12 +99,25 @@ private void ShowAudioAssetGUI(AudioAsset au,bool isShowAudioSource)
9999
}
100100
GUI.color = color;
101101
GUILayout.BeginVertical("box");
102-
GUILayout.Label("Asset Name : " + au.assetName);
102+
GUILayout.Label("Asset Name : " + au.AssetName);
103103
GUILayout.Label("Play State : " + au.PlayState);
104+
GUILayout.Label("Loop : " + au.audioSource.loop);
104105
GUILayout.Label("flag : " + au.flag);
105106
EditorGUILayout.Slider("VolumeScale : ",au.VolumeScale, 0, 1);
106-
107-
//EditorGUILayout.Slider("Volume : ", au.Volume, 0, au.GetMaxRealVolume());
107+
EditorGUILayout.Slider("Volume : ", au.GetMaxRealVolume(), 0, 1f);
108+
changedTime = GUILayout.Toggle(changedTime, "Change Time");
109+
GUILayout.BeginHorizontal();
110+
if (au.audioSource != null && au.audioSource.clip != null)
111+
{
112+
float value = EditorGUILayout.Slider("Time:" + au.audioSource.clip.length, au.audioSource.time, 0, au.audioSource.clip.length);
113+
if (changedTime)
114+
{
115+
au.audioSource.time = value;
116+
}
117+
}
118+
119+
GUILayout.EndHorizontal();
120+
108121
if (isShowAudioSource)
109122
EditorGUILayout.ObjectField("AudioSource : ", au.audioSource, typeof(AudioSource), true);
110123
GUILayout.EndVertical();

Assets/Script/Core/Data/Editor/Data/DataConfigUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public static object TableString2ObjectValue( string v, FieldType fieldValueType
176176
catch (Exception e)
177177
{
178178
t = Enum.GetValues(type).GetValue(0);
179-
// Debug.LogError("fieldValueType:" + fieldValueType + " enumType:" + enumType + " type:" + type + " v:" + v + "\n"+e);
179+
Debug.LogError("fieldValueType:" + fieldValueType + " enumType:" + enumType + " type:" + type + " v:" + v + "\n"+e);
180180
throw e;
181181
}
182182

Assets/Script/Core/Develop/DevelopReplayManager.cs

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -735,52 +735,56 @@ static void ProfileGUI()
735735

736736
static void DevelopHotKeyLogic()
737737
{
738-
if (Input.GetKeyDown(KeyCode.F2))
738+
if (Application.isEditor)
739739
{
740-
s_isProfile = !s_isProfile;
741-
}
742-
743-
if (Input.GetKeyDown(KeyCode.F3))
744-
{
745-
if (Time.timeScale != 0)
740+
if (Input.GetKeyDown(KeyCode.F2))
746741
{
747-
Time.timeScale = 0;
742+
s_isProfile = !s_isProfile;
748743
}
749-
else
744+
745+
if (Input.GetKeyDown(KeyCode.F3))
750746
{
751-
Time.timeScale = 1;
747+
if (Time.timeScale != 0)
748+
{
749+
Time.timeScale = 0;
750+
}
751+
else
752+
{
753+
Time.timeScale = 1;
754+
}
752755
}
753-
}
754756

755-
if (Input.GetKeyDown(KeyCode.F4))
756-
{
757-
if (Time.timeScale == 0)
757+
if (Input.GetKeyDown(KeyCode.F4))
758758
{
759-
Time.timeScale = 1;
759+
if (Time.timeScale == 0)
760+
{
761+
Time.timeScale = 1;
762+
}
763+
764+
Time.timeScale *= 2;
760765
}
761766

762-
Time.timeScale *= 2;
763-
}
767+
if (Input.GetKeyDown(KeyCode.F5))
768+
{
769+
Debug.Log("Time.timeScale " + Time.timeScale);
764770

765-
if (Input.GetKeyDown(KeyCode.F5))
766-
{
767-
Debug.Log("Time.timeScale " + Time.timeScale);
771+
if (Time.timeScale == 0)
772+
{
773+
Time.timeScale = 1;
774+
}
768775

769-
if (Time.timeScale == 0)
770-
{
771-
Time.timeScale = 1;
776+
Time.timeScale *= 0.5f;
772777
}
773778

774-
Time.timeScale *= 0.5f;
775-
}
776-
777-
if (Input.GetKeyDown(KeyCode.F10))
778-
{
779-
string name = GetScreenshotFileName();
780-
Debug.Log("已保存 屏幕截图 " + name);
779+
if (Input.GetKeyDown(KeyCode.F10))
780+
{
781+
string name = GetScreenshotFileName();
782+
Debug.Log("已保存 屏幕截图 " + name);
781783

782-
SaveScreenShot(name);
784+
SaveScreenShot(name);
785+
}
783786
}
787+
784788
}
785789

786790
#endregion

0 commit comments

Comments
 (0)