Unity音乐播放

1.Unity场景搭建

 

 2.脚本编码

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AudioPlay : MonoBehaviour
{
    //初始化播放对象
    public AudioSource audioMgr;
    void Start()
    {
        audioMgr = this.GetComponent<AudioSource>();
        //执行播放
        audioMgr.Play();
    }

    void Update()
    {
        
    }
}

  

posted @ 2023-02-08 14:50  打工仔-也想飞  阅读(100)  评论(0)    收藏  举报