feat: try to load music dynamically from JSON (WIP)

This commit is contained in:
2025-02-09 13:00:37 +01:00
parent 2c74515778
commit e3e6c9c036
5 changed files with 22 additions and 3 deletions

View File

@ -6,7 +6,7 @@ using UnityEngine.UI;
public class LevelLoader : MonoBehaviour
{
public Text levelNameText;
private Level level;
public Level level;
void Start()
{

View File

@ -1,11 +1,13 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using System.IO;
public class Player : MonoBehaviour
{
public Rigidbody2D rigidBody;
public GameObject playerObject;
public ParticleSystem particle;
public LevelLoader levelLoader;
public bool isColliding = true;
public AudioSource audioSource;
@ -15,10 +17,26 @@ public class Player : MonoBehaviour
public void Start()
{
// levelLoader = GameObject.FindGameObjectWithTag("LevelLoader").GetComponent<LevelLoader>();
var mainModule = particle.main;
mainModule.simulationSpace = ParticleSystemSimulationSpace.World;
particle.transform.parent = null;
// if (levelLoader.level != null)
// {
// string musicPath = Path.Combine("Musics", Path.GetFileNameWithoutExtension(levelLoader.level.MusicPath));
// AudioClip clip = Resources.Load<AudioClip>(musicPath);
// if (clip != null)
// {
// audioSource.clip = clip;
// audioSource.Play();
// }
// else
// {
// Debug.LogError("Failed to load music: " + musicPath);
// }
// }
Invoke(nameof(EnableInput), 0.1f);
}