I have a button that I added a sound effect using the onclick:
It works well but it doesnt work at all when transferring scenes as the sound doesnt play at all.
Is there any way to fix this?
I have a button that I added a sound effect using the onclick:
It works well but it doesnt work at all when transferring scenes as the sound doesnt play at all.
Is there any way to fix this?
I tried this script and it works but it saves the wrong gameobject as the new one that’s made when the scene loads is the one that plays the sound.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class dontdestoy : MonoBehaviour
{
void Awake()
{
GameObject[] objs = GameObject.FindGameObjectsWithTag("Music");
if (objs.Length > 1)
{
Destroy(this.gameObject);
}
DontDestroyOnLoad(this.gameObject);
}
}
I feel that there is a way around but I am not skilled enough to know it or find it.