Ejemplo n.º 1
0
        public IEnumerator SoundTest()
        {
            var outputPathSound = Application.streamingAssetsPath + "/InitTestAssetBundle/sound";

            Assert.AreEqual(2, SimpleAssetBundle.GetAllAssetNames(outputPathSound).Length);
            Assert.AreEqual(0, SimpleAssetBundle.GetAllScenePaths(outputPathSound).Length);

            Debug.Log(string.Join(Environment.NewLine, SimpleAssetBundle.GetAllAssetNames(outputPathSound)));

            var audioClip1 = SimpleAssetBundle.Load <AudioClip>(outputPathSound, SimpleAssetBundle.GetAllAssetNames(outputPathSound)[0]);

            yield return(null);

            Assert.AreEqual(1, SimpleAssetBundle.GetRefCount(outputPathSound));
            Assert.AreNotEqual(null, audioClip1);

            var audioClip2 = SimpleAssetBundle.Load <AudioClip>(outputPathSound, SimpleAssetBundle.GetAllAssetNames(outputPathSound)[1]);

            yield return(null);

            Assert.AreEqual(2, SimpleAssetBundle.GetRefCount(outputPathSound));
            Assert.AreNotEqual(null, audioClip2);

            SimpleAssetBundle.Unload(outputPathSound);
            yield return(null);

            Assert.AreEqual(1, SimpleAssetBundle.GetRefCount(outputPathSound));
            Assert.AreNotEqual(null, audioClip1);
            Assert.AreNotEqual(null, audioClip2);

            SimpleAssetBundle.Unload(outputPathSound);
            yield return(null);

            Assert.AreEqual(null, SimpleAssetBundle.GetRefCount(outputPathSound));

            SimpleAssetBundle.Unload(outputPathSound);
            yield return(null);

            Assert.AreEqual(null, SimpleAssetBundle.GetRefCount(outputPathSound));
        }