Giter Club home page Giter Club logo

skframework's Introduction

SKFramework

  • 本框架开发所用环境:Unity 2020.3.16
  • 请将SKFramework文件夹放在Assets根目录下使用

Audio

🎈一、背景音乐

🔸将一个AudioClip资产作为背景音乐进行播放

using UnityEngine;
using SK.Framework;

public class Example : MonoBehaviour
{
    [SerializeField] private AudioClip combat;

    private void Start()
    {
        Audio.BGM.Play(combat);        
    }
}   

🔸设置背景音乐是否循环

Audio.BGM.IsLoop = true;

🔸设置背景音乐音量

Audio.BGM.Volume = .3f;

🔸设置背景音乐是否暂停

Audio.BGM.IsPaused = true;

🔸设置背景音乐是否静音

Audio.BGM.IsMuted = true;

🎈二、音效

🔸将一个AudioClip资产作为音效进行播放

using UnityEngine;
using SK.Framework;

public class Example : MonoBehaviour
{
    [SerializeField] private AudioClip clip;

    private void Start()
    {
        Audio.SFX.Play(clip);
    }
}   

🔸在三维空间中的指定坐标位置播放音效

Audio.SFX.Play(clip, transform.position);

🔸音效跟随物体进行播放

Audio.SFX.Play(clip, transform);

🔸音效跟随物体进行播放

Audio.SFX.Play(clip, transform);

🔸所有播放音效的重载函数

🔸设置音效是否静音

Audio.SFX.IsMuted = true;

🔸设置音效是否暂停

Audio.SFX.IsPaused = true;

🔸停止所有音效播放

Audio.SFX.Stop();

🎈三、音频库

🔸创建音频库

🔸添加音频数据

AudioClip资产拖拽到Drop AudioClips Here区域以添加音频数据 为音频数据命名:

🔸加载音频库

Audio.Database.Load("ClickAudioDatabase", out AudioDatabase clickAudioDatabase);

第一个参数传入音频库资产的Resources路径

🔸卸载音频库

Audio.Database.Unload("Click");

参数传入音频库的名称

🔸获取音频库

同样的,参数传入音频库的名称

AudioDatabase database = Audio.Database.Get("Click");

🔸播放音频库中的音频

音频作为音效进行播放

Audio.Database.Load("ClickAudioDatabase", out AudioDatabase clickAudioDatabase);
clickAudioDatabase.PlayAsSFX("点击音效01");

音频作为背景音乐进行播放

Audio.Database.Load("ClickAudioDatabase", out AudioDatabase clickAudioDatabase);
clickAudioDatabase.PlayAsBGM("点击音效01");

//TODO:

skframework's People

Contributors

136512892 avatar runoob11 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.