Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Tommé Nöll
seedling
Commits
79c53857
Commit
79c53857
authored
Jul 06, 2019
by
Tommé Nöll
Browse files
music code refactor and loop examples
parent
67c85389
Changes
21
Hide whitespace changes
Inline
Side-by-side
Assets/Audio/Music/Testmusic.meta
0 → 100644
View file @
79c53857
fileFormatVersion: 2
guid: 10ec5dc53c6b3ea93a1b2a2acc1cc5ec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Assets/Audio/Music/Testmusic/CastleAmbience.asset
0 → 100644
View file @
79c53857
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!114
&11400000
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
0
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
614e8a5273c3faf5ca1c757762551768
,
type
:
3
}
m_Name
:
CastleAmbience
m_EditorClassIdentifier
:
clip
:
{
fileID
:
8300000
,
guid
:
3185935c8fd97032aa88f10c28258242
,
type
:
3
}
targets
:
-
musicObject
:
{
fileID
:
11400000
,
guid
:
da3cbe094e328eaf6993691cf8be4754
,
type
:
2
}
transitions
:
-
exitTime
:
140.802
targetEntryTime
:
140.802
isLoop
:
0
loopCounterpiece
:
{
fileID
:
11400000
,
guid
:
da3cbe094e328eaf6993691cf8be4754
,
type
:
2
}
Assets/Audio/Music/Testmusic/CastleAmbience.asset.meta
0 → 100644
View file @
79c53857
fileFormatVersion: 2
guid: fe0ed5b97b3d3a16d9ae8b7a3cc08572
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
Assets/Audio/Music/Testmusic/CastleAmbience.wav
0 → 100644
LFS
View file @
79c53857
File added
Assets/Audio/Music/Testmusic/CastleAmbience.wav.meta
0 → 100644
View file @
79c53857
fileFormatVersion: 2
guid: 3185935c8fd97032aa88f10c28258242
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
Assets/Audio/Music/Testmusic/CastleAmbienceLoop.asset
0 → 100644
View file @
79c53857
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!114
&11400000
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
0
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
614e8a5273c3faf5ca1c757762551768
,
type
:
3
}
m_Name
:
CastleAmbienceLoop
m_EditorClassIdentifier
:
clip
:
{
fileID
:
8300000
,
guid
:
4df6edb2a0fd9243dbd594804f2a39e6
,
type
:
3
}
targets
:
-
musicObject
:
{
fileID
:
11400000
,
guid
:
fe0ed5b97b3d3a16d9ae8b7a3cc08572
,
type
:
2
}
transitions
:
-
exitTime
:
140.802
targetEntryTime
:
140.802
isLoop
:
1
loopCounterpiece
:
{
fileID
:
11400000
,
guid
:
fe0ed5b97b3d3a16d9ae8b7a3cc08572
,
type
:
2
}
Assets/Audio/Music/Testmusic/CastleAmbienceLoop.asset.meta
0 → 100644
View file @
79c53857
fileFormatVersion: 2
guid: da3cbe094e328eaf6993691cf8be4754
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
Assets/Audio/Music/Testmusic/CastleAmbienceLoop.wav
0 → 100644
LFS
View file @
79c53857
File added
Assets/Audio/Music/Testmusic/CastleAmbienceLoop.wav.meta
0 → 100644
View file @
79c53857
fileFormatVersion: 2
guid: 4df6edb2a0fd9243dbd594804f2a39e6
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
Assets/Audio/Music/Testmusic/Cradles Looped.asset
0 → 100644
View file @
79c53857
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!114
&11400000
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
0
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
614e8a5273c3faf5ca1c757762551768
,
type
:
3
}
m_Name
:
Cradles Looped
m_EditorClassIdentifier
:
clip
:
{
fileID
:
8300000
,
guid
:
25d913b7338a1ef81a9f7563f87378e0
,
type
:
3
}
targets
:
-
musicObject
:
{
fileID
:
11400000
,
guid
:
2ebaa9d78fb7bfe58b40fd89bac4d5f2
,
type
:
2
}
transitions
:
-
exitTime
:
48.304
targetEntryTime
:
95.97
isLoop
:
1
loopCounterpiece
:
{
fileID
:
11400000
,
guid
:
2ebaa9d78fb7bfe58b40fd89bac4d5f2
,
type
:
2
}
Assets/Audio/Music/Testmusic/Cradles Looped.asset.meta
0 → 100644
View file @
79c53857
fileFormatVersion: 2
guid: 95882a6db4523a782a5aaf1a1065aa83
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
Assets/Audio/Music/Testmusic/Cradles.asset
0 → 100644
View file @
79c53857
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!114
&11400000
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
0
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
614e8a5273c3faf5ca1c757762551768
,
type
:
3
}
m_Name
:
Cradles
m_EditorClassIdentifier
:
clip
:
{
fileID
:
8300000
,
guid
:
000eba9f63f698b779f0e92f4056295c
,
type
:
3
}
targets
:
-
musicObject
:
{
fileID
:
11400000
,
guid
:
95882a6db4523a782a5aaf1a1065aa83
,
type
:
2
}
transitions
:
-
exitTime
:
47.665
targetEntryTime
:
0
isLoop
:
0
loopCounterpiece
:
{
fileID
:
11400000
,
guid
:
95882a6db4523a782a5aaf1a1065aa83
,
type
:
2
}
Assets/Audio/Music/Testmusic/Cradles.asset.meta
0 → 100644
View file @
79c53857
fileFormatVersion: 2
guid: 2ebaa9d78fb7bfe58b40fd89bac4d5f2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
Assets/Audio/Music/Testmusic/Testsong Looped Sub Urban - Cradles (shortened).ogg
0 → 100644
LFS
View file @
79c53857
File added
Assets/Audio/Music/Testmusic/Testsong Looped Sub Urban - Cradles (shortened).ogg.meta
0 → 100644
View file @
79c53857
fileFormatVersion: 2
guid: 25d913b7338a1ef81a9f7563f87378e0
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
Assets/Audio/Music/Testmusic/Testsong Sub Urban - Cradles (shortened).ogg
0 → 100644
LFS
View file @
79c53857
File added
Assets/Audio/Music/Testmusic/Testsong Sub Urban - Cradles (shortened).ogg.meta
0 → 100644
View file @
79c53857
fileFormatVersion: 2
guid: 000eba9f63f698b779f0e92f4056295c
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
Assets/Audio/Music/Tutorial.asset
View file @
79c53857
...
...
@@ -12,6 +12,15 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
614e8a5273c3faf5ca1c757762551768
,
type
:
3
}
m_Name
:
Tutorial
m_EditorClassIdentifier
:
targets
:
[]
clip
:
{
fileID
:
0
}
loop
:
0
targets
:
-
musicObject
:
{
fileID
:
11400000
,
guid
:
144ec059eee15b6b5b5ae05f72a452ad
,
type
:
2
}
transitions
:
-
exitTime
:
162
targetEntryTime
:
0
-
exitTime
:
10
targetEntryTime
:
15
clip
:
{
fileID
:
8300000
,
guid
:
99bfc60558e1ad300a5b0add036c0765
,
type
:
3
}
isLoop
:
0
loopCounterpiece
:
musicObject
:
{
fileID
:
0
}
transitions
:
[]
Assets/Scenes/TommeTest.unity
View file @
79c53857
...
...
@@ -760,6 +760,40 @@ Transform:
type
:
3
}
m_PrefabInstance
:
{
fileID
:
299385464
}
m_PrefabAsset
:
{
fileID
:
0
}
---
!u!84
&315585961
RenderTexture
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_Name
:
m_ImageContentsHash
:
serializedVersion
:
2
Hash
:
00000000000000000000000000000000
m_ForcedFallbackFormat
:
4
m_DownscaleFallback
:
0
serializedVersion
:
3
m_Width
:
1090
m_Height
:
539
m_AntiAliasing
:
1
m_DepthFormat
:
0
m_ColorFormat
:
21
m_MipMap
:
0
m_GenerateMips
:
1
m_SRGB
:
0
m_UseDynamicScale
:
0
m_BindMS
:
0
m_EnableCompatibleFormat
:
1
m_TextureSettings
:
serializedVersion
:
2
m_FilterMode
:
1
m_Aniso
:
1
m_MipBias
:
0
m_WrapU
:
1
m_WrapV
:
1
m_WrapW
:
1
m_Dimension
:
2
m_VolumeDepth
:
1
---
!u!1001
&339069304
PrefabInstance
:
m_ObjectHideFlags
:
0
...
...
@@ -4218,6 +4252,11 @@ PrefabInstance:
m_Modification
:
m_TransformParent
:
{
fileID
:
561089203
}
m_Modifications
:
-
target
:
{
fileID
:
1362442974637441874
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
propertyPath
:
m_Name
value
:
CorruptionZone (1)
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
146384502658720480
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
propertyPath
:
m_RootOrder
...
...
@@ -4243,11 +4282,6 @@ PrefabInstance:
propertyPath
:
m_LocalScale.x
value
:
4.02
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
1362442974637441874
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
propertyPath
:
m_Name
value
:
CorruptionZone (1)
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
1362442974637441875
,
guid
:
47edb6c4e8357676a9cb004f1655d229
,
type
:
3
}
propertyPath
:
maxStrengthDistanceFactor
...
...
@@ -4659,40 +4693,6 @@ PrefabInstance:
objectReference
:
{
fileID
:
0
}
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
7ef06ffc179d97098a6c30d5f8570a4e
,
type
:
3
}
---
!u!84
&1849961478
RenderTexture
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_Name
:
m_ImageContentsHash
:
serializedVersion
:
2
Hash
:
00000000000000000000000000000000
m_ForcedFallbackFormat
:
4
m_DownscaleFallback
:
0
serializedVersion
:
3
m_Width
:
1215
m_Height
:
528
m_AntiAliasing
:
1
m_DepthFormat
:
0
m_ColorFormat
:
21
m_MipMap
:
0
m_GenerateMips
:
1
m_SRGB
:
0
m_UseDynamicScale
:
0
m_BindMS
:
0
m_EnableCompatibleFormat
:
1
m_TextureSettings
:
serializedVersion
:
2
m_FilterMode
:
1
m_Aniso
:
1
m_MipBias
:
0
m_WrapU
:
1
m_WrapV
:
1
m_WrapW
:
1
m_Dimension
:
2
m_VolumeDepth
:
1
---
!u!1001
&1854361418
PrefabInstance
:
m_ObjectHideFlags
:
0
...
...
@@ -5530,7 +5530,7 @@ PrefabInstance:
type
:
3
}
propertyPath
:
m_TargetTexture
value
:
objectReference
:
{
fileID
:
1849961478
}
objectReference
:
{
fileID
:
315585961
}
-
target
:
{
fileID
:
8811539149977030266
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
m_LocalPosition.x
...
...
@@ -5596,6 +5596,11 @@ PrefabInstance:
propertyPath
:
corruptionMap
value
:
objectReference
:
{
fileID
:
120497678
}
-
target
:
{
fileID
:
5104620888276671122
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
m_Enabled
value
:
0
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
8811539149977030261
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
propertyPath
:
player
...
...
@@ -5603,3 +5608,25 @@ PrefabInstance:
objectReference
:
{
fileID
:
0
}
m_RemovedComponents
:
[]
m_SourcePrefab
:
{
fileID
:
100100000
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
---
!u!1
&8811539148946952084
stripped
GameObject
:
m_CorrespondingSourceObject
:
{
fileID
:
8811539149977030262
,
guid
:
388a7af523fdebaafad4a5d1ae1a896b
,
type
:
3
}
m_PrefabInstance
:
{
fileID
:
8811539148946952083
}
m_PrefabAsset
:
{
fileID
:
0
}
---
!u!114
&8811539148946952085
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
8811539148946952084
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
63226443539043ad88666eb1da52af02
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
startMusic
:
{
fileID
:
11400000
,
guid
:
2ebaa9d78fb7bfe58b40fd89bac4d5f2
,
type
:
2
}
startMusicLoop
:
{
fileID
:
0
}
startTime
:
0
transitionLagOffset
:
0
Assets/Scripts/Audio/BackgroundMusic.cs
View file @
79c53857
...
...
@@ -6,7 +6,7 @@ public class BackgroundMusic : MonoBehaviour {
private
int
current
=
0
;
//currently used audio source
//public AudioClip Ambience, Combat;
public
MusicObject
startMusic
,
startMusicLoop
;
public
MusicObject
startMusic
;
private
MusicObject
currentMusic
,
queuedMusic
;
public
int
startTime
=
0
;
public
int
transitionLagOffset
=
2000
;
...
...
@@ -18,10 +18,14 @@ public class BackgroundMusic : MonoBehaviour {
// Use this for initialization
void
Start
()
{
startTime
*=
startMusic
.
clip
.
frequency
;
AS
=
GetComponents
<
AudioSource
>();
if
(
AS
.
Length
!=
2
)
Debug
.
LogError
(
"Background Music object \""
+
gameObject
.
name
+
"\" doesn't have exactly 2 Audio Sources"
);
AS
=
new
AudioSource
[]
{
gameObject
.
AddComponent
<
AudioSource
>(),
gameObject
.
AddComponent
<
AudioSource
>()};
Play
(
startMusic
,
0
,
startTime
);
TransitionTo
(
startMusicLoop
);
MusicObject
startMusicLoop
=
startMusic
.
loopCounterpiece
;
if
(
startMusicLoop
!=
null
)
{
TransitionTo
(
startMusicLoop
);
}
}
void
Update
()
...
...
@@ -139,4 +143,10 @@ public class BackgroundMusic : MonoBehaviour {
"\nGlobal Transition Time: " + dspTransitionTime);*/
Play
(
target
,
exitSample
,
targetEntrySample
);
}
[
ContextMenu
(
"Transition to Start Music"
)]
private
void
TransitionToStartMusic
()
{
TransitionTo
(
startMusic
);
}
}
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment