mirror of
https://github.com/Steffo99/gravity-fusion.git
synced 2024-11-22 00:14:18 +00:00
Music smoothing
This commit is contained in:
parent
f0d968c80f
commit
869e2f608d
14 changed files with 408 additions and 23 deletions
4
Assets/Code/AfterStart.cs
Normal file
4
Assets/Code/AfterStart.cs
Normal file
|
@ -0,0 +1,4 @@
|
|||
//From https://answers.unity.com/questions/442342/how-to-make-public-variable-read-only-during-run-t.html
|
||||
using UnityEngine;
|
||||
|
||||
public class AfterStart : PropertyAttribute {}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9903d7c519b2c6849943c4d6b8dab4bf
|
||||
guid: 9fae7738546fcf6408a8a1e986460fda
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
4
Assets/Code/BeforeStart.cs
Normal file
4
Assets/Code/BeforeStart.cs
Normal file
|
@ -0,0 +1,4 @@
|
|||
//From https://answers.unity.com/questions/442342/how-to-make-public-variable-read-only-during-run-t.html
|
||||
using UnityEngine;
|
||||
|
||||
public class BeforeStart : PropertyAttribute {}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: de6a180c8ef2dbd44ae2fd0f7a040623
|
||||
guid: c80c3920999989b4b920fe2953ade20e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -7,7 +7,13 @@ using UnityEngine;
|
|||
public class MusicManager : MonoBehaviour
|
||||
{
|
||||
public AudioSource baseLayer;
|
||||
public List<AudioSource> layers;
|
||||
public float changeSpeed = 1f;
|
||||
|
||||
[BeforeStart]
|
||||
public AudioSource[] layers;
|
||||
|
||||
protected float baseLayerTargetVolume;
|
||||
protected float[] targetVolume;
|
||||
|
||||
protected bool neverStarted;
|
||||
|
||||
|
@ -16,15 +22,20 @@ public class MusicManager : MonoBehaviour
|
|||
foreach(AudioSource audioSource in layers) {
|
||||
audioSource.volume = 0;
|
||||
}
|
||||
targetVolume = new float[layers.Length];
|
||||
for(int i = 0; i < layers.Length; i++) {
|
||||
targetVolume[i] = 0f;
|
||||
}
|
||||
baseLayerTargetVolume = 1f;
|
||||
neverStarted = true;
|
||||
}
|
||||
|
||||
public void UpdateLayers(int maxTier) {
|
||||
if(maxTier == -1) {
|
||||
baseLayer.volume = 1f;
|
||||
baseLayerTargetVolume = 1f;
|
||||
}
|
||||
else {
|
||||
baseLayer.volume = 0f;
|
||||
baseLayerTargetVolume = 0f;
|
||||
}
|
||||
|
||||
if(neverStarted) {
|
||||
|
@ -34,20 +45,39 @@ public class MusicManager : MonoBehaviour
|
|||
neverStarted = false;
|
||||
}
|
||||
|
||||
if(maxTier >= layers.Count) {
|
||||
foreach(AudioSource layer in layers) {
|
||||
layer.volume = 1f;
|
||||
if(maxTier >= layers.Length) {
|
||||
for(int i = 0; i < layers.Length; i++) {
|
||||
targetVolume[i] = 1f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int i = 0; i < layers.Count; i++) {
|
||||
for(int i = 0; i < layers.Length; i++) {
|
||||
if(maxTier >= i) {
|
||||
layers[i].volume = 1f;
|
||||
targetVolume[i] = 1f;
|
||||
}
|
||||
else {
|
||||
layers[i].volume = 0f;
|
||||
targetVolume[i] = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void Update() {
|
||||
if(baseLayer.volume > baseLayerTargetVolume) {
|
||||
baseLayer.volume = Mathf.Clamp(baseLayer.volume - Time.deltaTime * changeSpeed, baseLayerTargetVolume, float.PositiveInfinity);
|
||||
}
|
||||
else if(baseLayer.volume < baseLayerTargetVolume) {
|
||||
baseLayer.volume = Mathf.Clamp(baseLayer.volume + Time.deltaTime * changeSpeed, 0f, baseLayerTargetVolume);
|
||||
}
|
||||
|
||||
for(int i = 0; i < layers.Length; i++) {
|
||||
if(layers[i].volume > targetVolume[i]) {
|
||||
layers[i].volume = Mathf.Clamp(layers[i].volume - Time.deltaTime * changeSpeed, targetVolume[i], float.PositiveInfinity);
|
||||
}
|
||||
else if(layers[i].volume < targetVolume[i]) {
|
||||
layers[i].volume = Mathf.Clamp(layers[i].volume + Time.deltaTime * changeSpeed, 0f, targetVolume[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,5 +19,3 @@ public class AfterStartAttributeDrawer : PropertyDrawer
|
|||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public class AfterStart : PropertyAttribute {}
|
11
Assets/Editor/AfterStartAttributeDrawer.cs.meta
Normal file
11
Assets/Editor/AfterStartAttributeDrawer.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bb6935448ef8afa40b70179ed82526f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,4 +1,4 @@
|
|||
//From https://answers.unity.com/questions/442342/how-to-make-public-variable-read-only-during-run-t.html
|
||||
//From https://answers.unity.com/questions/442342/how-to-make-public-variable-read-only-during-run-t.html
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
|
@ -18,6 +18,4 @@ public class BeforeStartAttributeDrawer : PropertyDrawer
|
|||
EditorGUI.PropertyField(position, property, label, true);
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BeforeStart : PropertyAttribute {}
|
||||
}
|
11
Assets/Editor/BeforeStartAttributeDrawer.cs.meta
Normal file
11
Assets/Editor/BeforeStartAttributeDrawer.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0c5fc3bdbfd0b2c4cb8ffcc597e1d884
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
22
Assets/Music/layer2.ogg.meta
Normal file
22
Assets/Music/layer2.ogg.meta
Normal file
|
@ -0,0 +1,22 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7f5aa2a2cf682734ba7c9842badb7b84
|
||||
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:
|
|
@ -1,5 +1,132 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1636788349
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1636788350}
|
||||
- component: {fileID: 1636788351}
|
||||
m_Layer: 0
|
||||
m_Name: Layer 2
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1636788350
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1636788349}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1990625892755510357}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!82 &1636788351
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1636788349}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 8300000, guid: 7f5aa2a2cf682734ba7c9842badb7b84, type: 3}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 1
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
panLevelCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spreadCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMixCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!1 &2840017336573732720
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -42,7 +169,7 @@ AudioSource:
|
|||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 8300000, guid: 37e30c686763c1e4ca22b20a356252c0, type: 3}
|
||||
m_PlayOnAwake: 1
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 1
|
||||
|
@ -392,8 +519,10 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
baseLayer: {fileID: 787973444833592173}
|
||||
changeSpeed: 1
|
||||
layers:
|
||||
- {fileID: 4850948939192426854}
|
||||
- {fileID: 1636788351}
|
||||
--- !u!1 &7887871963136015922
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -550,6 +679,7 @@ Transform:
|
|||
m_Children:
|
||||
- {fileID: 2826821897386302087}
|
||||
- {fileID: 576137496605705657}
|
||||
- {fileID: 1636788350}
|
||||
m_Father: {fileID: 9012813807232547518}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
|
@ -590,11 +590,6 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4850948939192426854, guid: bf08d766b6e86cf4a8773489143ab2d5,
|
||||
type: 3}
|
||||
propertyPath: m_PlayOnAwake
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: bf08d766b6e86cf4a8773489143ab2d5, type: 3}
|
||||
--- !u!1001 &9221969453494073200
|
||||
|
|
91
Assets/Sprites/5_Aura_pianeta.png.meta
Normal file
91
Assets/Sprites/5_Aura_pianeta.png.meta
Normal file
|
@ -0,0 +1,91 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e4ec9161cccbbf6418c6303578c92a09
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
91
Assets/Sprites/5_Planet.png.meta
Normal file
91
Assets/Sprites/5_Planet.png.meta
Normal file
|
@ -0,0 +1,91 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cf0aaa5da1a763b4ca8944ec483ffb86
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 10
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 5e97eb03825dee720800000000000000
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in a new issue