Cambio de cancion al iniciar nivel

parent d5228a1a
Showing with 194 additions and 42 deletions
......@@ -63,6 +63,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\CambioCancion.cs" />
<Compile Include="Assets\MainMenu\Scripts\MainMenu.cs" />
<Compile Include="Assets\MainMenu\Scripts\MenuExtras.cs" />
<Compile Include="Assets\MainMenu\Scripts\MenusCreditos.cs" />
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CambioCancion : MonoBehaviour
{
private void Awake()
{
Musica.CambiarCancion();
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: 379826b7faee1344895a77dab75ab357
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -11,6 +11,7 @@ GameObject:
- component: {fileID: 7736364748447018736}
- component: {fileID: 3174322665456641310}
- component: {fileID: 1646803205624574402}
- component: {fileID: 8228429523814113897}
m_Layer: 0
m_Name: GameManager
m_TagString: Untagged
......@@ -75,3 +76,15 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
enemigo: {fileID: 3326548381514800793, guid: 4cad856fb8f87054e8cb7d66b4d1e74e, type: 3}
--- !u!114 &8228429523814113897
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7736364748447018738}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 379826b7faee1344895a77dab75ab357, type: 3}
m_Name:
m_EditorClassIdentifier:
fileFormatVersion: 2
guid: 42e2019a92d62f940b4b5208d976f815
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d6336a6155db3c54d8ced019fe197e27
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 438c86200882abc4b86edb23851841d3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
The file could not be displayed because it is too large.
fileFormatVersion: 2
guid: 3fdf7f6c94857174a95f096899fd0d81
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:
......@@ -344,6 +344,21 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2114081506731414284, guid: 8e30a5e6158f5374184178db3778780b,
type: 3}
propertyPath: m_audioClip
value:
objectReference: {fileID: 0}
- target: {fileID: 2114081506731414284, guid: 8e30a5e6158f5374184178db3778780b,
type: 3}
propertyPath: Loop
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2114081506731414284, guid: 8e30a5e6158f5374184178db3778780b,
type: 3}
propertyPath: m_Volume
value: 0.987
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 8e30a5e6158f5374184178db3778780b, type: 3}
--- !u!1 &395722973
......
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Musica : MonoBehaviour
{
//https://answers.unity.com/questions/1041174/help-playing-audio-depending-on-scene.html
//https://www.youtube.com/watch?v=3mK5dD9XH_U
public static Musica musica;
private void Awake()
{
/*Hacemos que este objeto no se destruya en un
cambio de escena para que no se corte el audio.*/
if (musica == null)
{
musica = this;
......@@ -16,16 +22,49 @@ public class Musica : MonoBehaviour
{
Destroy(gameObject);
}
//Cargamos el audio correspondiente a la escena.
AudioSource audio = musica.GetComponent<AudioSource>();
if (SceneManager.GetActiveScene().name == "MenuInicial")
{
Debug.Log("si");
audio.clip = Resources.Load("Musica/Juego/MusicTales_MenuInicial") as AudioClip;
Debug.Log(audio.clip.name);
audio.Play();
}
else if (SceneManager.GetActiveScene().name == "SampleScene")
{
audio.clip = Resources.Load("Musica/Juego/MusicTales_Nivel1") as AudioClip;
audio.Play();
}
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
//Declaramos como estático para poder llamar desde otros scripts.
public static void CambiarCancion()
{
//Cambiamos el audio y ajustamos el volumen.
AudioSource audio = musica.GetComponent<AudioSource>();
audio.clip = Resources.Load("Musica/Juego/MusicTales_Nivel1") as AudioClip;
audio.volume = 0.2f;
audio.Play();
}
}
......@@ -44,10 +44,10 @@ MonoBehaviour:
y: 30
width: 1366
height: 635
m_MinSize: {x: 683, y: 494}
m_MaxSize: {x: 14004, y: 14044}
m_MinSize: {x: 681, y: 344}
m_MaxSize: {x: 12006, y: 8044}
vertical: 0
controlID: 152
controlID: 97
--- !u!114 &3
MonoBehaviour:
m_ObjectHideFlags: 52
......@@ -67,8 +67,8 @@ MonoBehaviour:
y: 0
width: 389
height: 635
m_MinSize: {x: 277, y: 72}
m_MaxSize: {x: 4002, y: 4022}
m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 14}
m_Panes:
- {fileID: 14}
......@@ -119,15 +119,15 @@ MonoBehaviour:
y: 359
width: 977
height: 276
m_MinSize: {x: 232, y: 272}
m_MaxSize: {x: 10002, y: 10022}
m_ActualView: {fileID: 13}
m_MinSize: {x: 102, y: 122}
m_MaxSize: {x: 4002, y: 4022}
m_ActualView: {fileID: 18}
m_Panes:
- {fileID: 13}
- {fileID: 18}
- {fileID: 12}
m_Selected: 0
m_LastSelected: 1
m_Selected: 1
m_LastSelected: 0
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
......@@ -216,10 +216,10 @@ MonoBehaviour:
y: 0
width: 977
height: 635
m_MinSize: {x: 406, y: 494}
m_MaxSize: {x: 10002, y: 14044}
m_MinSize: {x: 406, y: 344}
m_MaxSize: {x: 8006, y: 8044}
vertical: 1
controlID: 78
controlID: 32
--- !u!114 &10
MonoBehaviour:
m_ObjectHideFlags: 52
......@@ -244,7 +244,7 @@ MonoBehaviour:
m_MinSize: {x: 406, y: 222}
m_MaxSize: {x: 8006, y: 4022}
vertical: 0
controlID: 79
controlID: 33
--- !u!114 &11
MonoBehaviour:
m_ObjectHideFlags: 52
......@@ -300,7 +300,7 @@ MonoBehaviour:
m_ViewDataDictionary: {fileID: 0}
m_LockTracker:
m_IsLocked: 0
m_LastSelectedObjectID: 57604
m_LastSelectedObjectID: -434222
--- !u!114 &13
MonoBehaviour:
m_ObjectHideFlags: 52
......@@ -339,34 +339,34 @@ MonoBehaviour:
m_ShowAllHits: 0
m_SearchArea: 1
m_Folders:
- Assets
- Assets/Scenes
m_ViewMode: 1
m_StartGridSize: 64
m_LastFolders:
- Assets
- Assets/Scenes
m_LastFoldersGridSize: -1
m_LastProjectPath: C:\Users\alvmo\Documents\NetBeansProjects\DesarrolloDeVideojuegos_Proyecto\Videojuegos_Proyecto
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 19}
m_SelectedIDs: 822a0000
m_LastClickedID: 10882
m_ExpandedIDs: 00000000822a0000de33000000ca9a3b
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 1c390000
m_LastClickedID: 14620
m_ExpandedIDs: 00000000403800009841000000ca9a3b
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
m_OriginalName:
m_Name: Scenes
m_OriginalName: Scenes
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 0
m_UserData: 14620
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 11
m_OriginalEventType: 0
m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 5}
m_SearchString:
......@@ -380,7 +380,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 00000000822a0000de330000
m_ExpandedIDs: 000000004038000098410000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
......@@ -405,8 +405,8 @@ MonoBehaviour:
m_Icon: {fileID: 0}
m_ResourceFile:
m_ListAreaState:
m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0
m_SelectedInstanceIDs: d25ff9ff
m_LastClickedInstanceID: -434222
m_HadKeyboardFocusLastEvent: 1
m_ExpandedInstanceIDs: c6230000a83200001c2c0000462b00004afc000000000000
m_RenameOverlay:
......@@ -500,9 +500,9 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: a02a0000
m_LastClickedID: 0
m_ExpandedIDs: 8cfbffff
m_SelectedIDs: d25ff9ff
m_LastClickedID: -434222
m_ExpandedIDs: d45ff9ff9ebff9ff541ffaff0220faffae81faff04e2faff4242fbff0830fdff92f9fdff542cfeff5c59feff9a59feff02b9feff5e18ffffba77ffff7aabffff82d8fffff4ffffff665c00008e5c0000b0670000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
......@@ -562,9 +562,9 @@ MonoBehaviour:
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: 5.6208262, y: -4.1250525, z: -82.3524}
m_Target: {x: 28.230677, y: -5.145041, z: -82.35156}
speed: 2
m_Value: {x: 5.6208262, y: -4.1250525, z: -82.3524}
m_Value: {x: 28.230677, y: -5.145041, z: -82.35156}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
......@@ -726,8 +726,8 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 0
y: 748
width: 1373
height: 253
x: 292
y: 1512
width: 977
height: 257
m_ViewDataDictionary: {fileID: 0}
sceneSetups:
- path: Assets/Scenes/SampleScene.unity
- path: Assets/Scenes/MenuInicial.unity
isLoaded: 1
isActive: 1
isSubScene: 0
{"m_ExpandedPrefabGameObjectFileIDs":[],"m_ExpandedSceneGameObjectInstanceIDs":[],"m_ScrollY":0.0,"m_LastClickedFileID":2114081506731414285,"m_LastClickedInstanceID":0}
\ No newline at end of file
{"cameraMode":{"drawMode":0,"name":"Shaded","section":"Shading Mode"},"sceneLighting":false,"audioPlay":false,"sceneViewState":{"showFog":true,"showMaterialUpdate":false,"showSkybox":false,"showFlares":true,"showImageEffects":true,"showParticleSystems":true},"in2DMode":true,"pivot":{"x":-2.81071138381958,"y":-1.2284358739852906,"z":-161.0322265625},"rotation":{"x":0.0,"y":0.0,"z":0.0,"w":1.0},"size":22.0,"orthographic":true}
\ No newline at end of file
{"cameraMode":{"drawMode":0,"name":"Shaded","section":"Shading Mode"},"sceneLighting":true,"audioPlay":false,"sceneViewState":{"showFog":true,"showMaterialUpdate":false,"showSkybox":true,"showFlares":true,"showImageEffects":true,"showParticleSystems":true},"in2DMode":true,"pivot":{"x":5.620826244354248,"y":-4.125052452087402,"z":-82.35240173339844},"rotation":{"x":0.0,"y":0.0,"z":0.0,"w":1.0},"size":56.66680145263672,"orthographic":true}
\ No newline at end of file
{"cameraMode":{"drawMode":0,"name":"Shaded","section":"Shading Mode"},"sceneLighting":true,"audioPlay":false,"sceneViewState":{"showFog":true,"showMaterialUpdate":false,"showSkybox":true,"showFlares":true,"showImageEffects":true,"showParticleSystems":true},"in2DMode":true,"pivot":{"x":28.230676651000978,"y":-5.145040988922119,"z":-82.3515625},"rotation":{"x":0.0,"y":0.0,"z":0.0,"w":1.0},"size":56.66680145263672,"orthographic":true}
\ No newline at end of file
......@@ -17,6 +17,7 @@ TagManager:
- PU_Ataque
- HitBoxMelee
- PlataformaMovil
- Musica
layers:
- Default
- TransparentFX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment