示例#1
0
        /// <summary>
        /// Use this to play audios from a specific bundleManager
        /// </summary>
        /// <param name="bundleManager">From which bundleManager the audio will be fetch</param>
        /// <param name="audioTag">Use PYAudioTags that start with a B_</param>
        /// <param name="group">In which group/channel this audio will be played</param>
        /// <returns></returns>
        public PYAudioSource StartAudio(PYBundleSubManager bundleManager, PYAudioTags audioTag, PYGroupTag group)
        {
            PYAudioSource audioSource = GetPYAudioSource(audioTag);

            if (audioSource != null && audioSource.Track.GroupTag == PYGroupTag.Voice)
            {
                return(audioSource);
            }

            return(StartAudio(audioTag, new AudioTrack(group, bundleManager.GetAsset <AudioClip>(audioTag.ToString().Replace("B_", "")))));
        }
示例#2
0
        /// <summary>
        /// Get a asset from the list of bundles type, using its assetTag
        /// and its type
        /// </summary>
        /// <typeparam name="T">Asset type</typeparam>
        /// <param name="bundlesToCheck">List of bundlesType to check(The last on list more priority it has)</param>
        /// <param name="assetTag">Asset tag</param>
        /// <returns>Returns the asset from the Type or null if not found</returns>
        public static T GetAsset <T>(PYBundleType[] bundlesToCheck, string assetTag)
        {
            if (string.IsNullOrEmpty(assetTag) || assetTag == "None")
            {
                return(default(T));
            }

            T asset = default(T);

            // We check starting from the last because the last one will always have
            // priority over the first, so if we find the asset in the last we dont
            // need to just the others
            for (int x = bundlesToCheck.Length - 1; x >= 0; x--)
            {
                PYBundleSubManager manager = null;
                switch (bundlesToCheck[x])
                {
                case PYBundleType.Content: manager = PYBundleManager.Content; break;

                case PYBundleType.Data: manager = PYBundleManager.Data; break;

                case PYBundleType.Localization: manager = PYBundleManager.Localization; break;
                }

                if (manager == null)
                {
                    continue;
                }

                asset = manager.GetAsset <T>(assetTag);
                if (asset != null)
                {
                    return(asset);
                }
            }

#if UNITY_EDITOR
            if (asset == null && !string.IsNullOrEmpty(assetTag) && assetTag != "None")
            {
                Debug.LogWarning(string.Format("BundleAsset({0}: {1}) was not found!", assetTag, typeof(T)));
            }
#endif

            // In case any asset hasn't been found in the managers
            // we return null
            return(asset);
        }