源代码详情

返回代码列表
C++

最终场景带音效源码

作者: 超级管理员 发布时间: 2025-11-15 13:54 下载次数: 11 最后更新: 2025-11-17 12:42
最终场景带音效源码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class testMusice : MonoBehaviour
{

    private static testMusice instance = null;
    public static testMusice Instance
    {
        get { return instance; }
    }
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
        }
        DontDestroyOnLoad(this.gameObject);//使对象目标在加载新场景时不被自动销毁。
    }
    //public void onChangeSceneButtonClicked()
    //{
    //changeScene("scene3");
    // }
    //切换场景
    public void start(int Scene)
    {
        SceneManager.LoadScene(Scene);
    }
}