Exemple #1
0
        private static void Init()
        {
            //已经初始化则不处理了
            if (null != self)
            {
                return;
            }

            self = GameObject.FindObjectOfType <KAssetBundle>();
            if (self == null)
            {
                KLogger.Log("开始初始化|KAssetBundle");

                GameObject go = new GameObject();
                go.name = "__KAssetBundle__";
                DontDestroyOnLoad(go);                 //场景切换也保留

                self = go.AddComponent <KAssetBundle>();
            }
        }
Exemple #2
0
 /// <summary>
 /// 调用oneShotAudioSource的PlayOneShot播放音频文件,直接使用已经预加载的AB资源
 /// </summary>
 /// <param name="volumeScale">音量缩放比</param>
 public static void PlayOneShot(string audioABName, float volumeScale = 1.0f)
 {
     PlayOneShot(KAssetBundle.GetObject <AudioClip>(audioABName), volumeScale);
 }
Exemple #3
0
 /// <summary>
 /// 调用bgAudioSource的Play播放音频文件,,直接使用已经预加载的AB资源
 /// </summary>
 /// <param name="volumeScale">音量缩放比</param>
 public static void PlayBg(string audioABName, float volumeScale = 1.0f)
 {
     KSound.PlayBg(KAssetBundle.GetObject <AudioClip>(audioABName), volumeScale);
 }