diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index e8e0c52c..4fd53783 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -19238,8 +19238,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1589389272} m_HandleRect: {fileID: 1589389271} m_Direction: 2 - m_Value: 1 - m_Size: 0.99952716 + m_Value: 0 + m_Size: 1 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -24820,7 +24820,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 0, y: 129.91016} + m_AnchoredPosition: {x: 0, y: 129.9111} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!114 &1154875944 @@ -35580,9 +35580,9 @@ MonoBehaviour: m_PersistentCalls: m_Calls: - m_Target: {fileID: 1423699437} - m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.Editor, Assembly-CSharp - m_MethodName: LoadRemix - m_Mode: 5 + m_TargetAssemblyTypeName: HeavenStudio.Editor.Editor, Assembly-CSharp + m_MethodName: NewRemix + m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine diff --git a/Assets/Scripts/LevelEditor/Editor.cs b/Assets/Scripts/LevelEditor/Editor.cs index 203cd65c..8e3bb6b8 100644 --- a/Assets/Scripts/LevelEditor/Editor.cs +++ b/Assets/Scripts/LevelEditor/Editor.cs @@ -70,6 +70,8 @@ namespace HeavenStudio.Editor public bool editingInputField = false; public bool isCursorEnabled = true; + private byte[] MusicBytes; + public static Editor instance { get; private set; } private void Start() @@ -158,7 +160,7 @@ namespace HeavenStudio.Editor { if (Input.GetKeyDown(KeyCode.N)) { - LoadRemix(""); + NewRemix(); } else if (Input.GetKeyDown(KeyCode.O)) { @@ -294,6 +296,22 @@ namespace HeavenStudio.Editor } } + try + { + if (clip != null) + MusicBytes = OggVorbis.VorbisPlugin.GetOggVorbis(Conductor.instance.musicSource.clip, 1); + else + { + MusicBytes = null; + Debug.LogWarning("Failed to load music file! The stream is currently empty."); + } + } + catch (System.Exception) + { + MusicBytes = null; + Debug.LogWarning("Failed to load music file! The stream is currently empty."); + } + return clip; } @@ -343,15 +361,12 @@ namespace HeavenStudio.Editor using (var zipStream = levelFile.Open()) zipStream.Write(Encoding.UTF8.GetBytes(GetJson()), 0, Encoding.UTF8.GetBytes(GetJson()).Length); - if (changedMusic || currentRemixPath != path) + if (MusicBytes != null) { - // this gets rid of the music file for some reason, someone remind me to find a fix for this soon + var musicFile = archive.CreateEntry("song.ogg", System.IO.Compression.CompressionLevel.NoCompression); + using (var zipStream = musicFile.Open()) + zipStream.Write(MusicBytes, 0, MusicBytes.Length); } - - byte[] bytes = OggVorbis.VorbisPlugin.GetOggVorbis(Conductor.instance.musicSource.clip, 1); - var musicFile = archive.CreateEntry("song.ogg", System.IO.Compression.CompressionLevel.NoCompression); - using (var zipStream = musicFile.Open()) - zipStream.Write(bytes, 0, bytes.Length); } currentRemixPath = path; @@ -359,6 +374,12 @@ namespace HeavenStudio.Editor } } + public void NewRemix() + { + MusicBytes = null; + LoadRemix(""); + } + public void LoadRemix(string json = "") { GameManager.instance.LoadRemix(json); @@ -367,6 +388,8 @@ namespace HeavenStudio.Editor Timeline.instance.VolumeInfo.UpdateStartingVolumeText(); Timeline.instance.TempoInfo.UpdateOffsetText(); Timeline.FitToSong(); + + currentRemixPath = string.Empty; } public void OpenRemix() @@ -408,12 +431,11 @@ namespace HeavenStudio.Editor { using (var stream = entry.Open()) { - byte[] bytes; using (var ms = new MemoryStream()) { stream.CopyTo(ms); - bytes = ms.ToArray(); - Conductor.instance.musicSource.clip = OggVorbis.VorbisPlugin.ToAudioClip(bytes, "music"); + MusicBytes = ms.ToArray(); + Conductor.instance.musicSource.clip = OggVorbis.VorbisPlugin.ToAudioClip(MusicBytes, "music"); loadedMusic = true; Timeline.FitToSong(); } diff --git a/Assets/StreamingAssets/StreamingAssets.manifest b/Assets/StreamingAssets/StreamingAssets.manifest index 9d090fdc..01a4f57e 100644 --- a/Assets/StreamingAssets/StreamingAssets.manifest +++ b/Assets/StreamingAssets/StreamingAssets.manifest @@ -1,5 +1,5 @@ ManifestFileVersion: 0 -CRC: 1477632056 +CRC: 1516953164 AssetBundleManifest: AssetBundleInfos: Info_0: