Ejemplo n.º 1
0
        /// <summary>
        /// Loads a base <see cref="AudioClip"/> from disk
        /// </summary>
        /// <returns>
        /// A base <see cref="AudioClip"/>
        /// </returns>
        /// <param name='path'>
        /// Path to audio file
        /// </param>
        /// <param name='stream'>
        /// Whether or not the <see cref="AudioClip"/> should be fully loaded into memory or streamed from disk
        /// </param>
        private static AudioClip LoadAudioClip(string path, bool stream)
        {
            string filePath = SysPath.FindFile(path, SysPath.AudioExtensions);

            if (filePath == null)
            {
                Logger.Error(TAG, String.Format("Unable to find audio file: \"{0}\"", path));
                return(null);
            }

            string url = SysPath.GetWwwPath(filePath);
            WWW    www = new WWW(url);
            //while (!www.isDone); // FIXME: Is blocking here necessary?

            AudioClip clip;

            clip = www.GetAudioClip(false, stream);
            while (!clip.isReadyToPlay)
            {
                ;                      // Wait for buffer
            }
            www.Dispose();             // FIXME: What does this even do? Documentation is blank...

            if (clip == null)
            {
                Logger.Error(TAG, String.Format("Unable to load audio file: \"{0}\"", url));
            }
            return(clip);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds a file. Uses <see cref="SysPath.FindFile"/>
        /// </summary>
        /// <returns>
        /// The path to the file, null if not found
        /// </returns>
        /// <param name='name'>
        /// Name of key being parsed for
        /// </param>
        /// <param name='val'>
        /// Value string being parsed
        /// </param>
        /// <param name='fatal'>
        /// Whether or not a <see cref="ParserException"/> should be thrown upon parsing error
        /// </param>
        /// <param name='type'>
        /// Type of file
        /// </param>
        /// <param name='extensions'>
        /// List of file extensions to check with
        /// </param>
        public string FindFile(string name, string val, bool fatal, string type, string[] extensions)
        {
            string path = SysPath.FindFile(SysPath.GetPath(_info.folder, val), extensions);

            if (path == null)
            {
                string msg = String.Format("Unable to find {0} {1} file: {2}", name, type, val);
                if (fatal)
                {
                    Error(msg);
                }
                else
                {
                    Warning(msg);
                }
            }
            return(path);
        }