예제 #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);
        }
예제 #2
0
        public static Texture2D LoadTexture(string path, bool repeat)
        {
            Texture2D texture;
            WWW       www = new WWW(SysPath.GetWwwPath(path));

            while (!www.isDone)
            {
                ;                            // FIXME: Blocks, thread this?
            }
            texture          = www.texture;  // Compare with www.LoadImageIntoTexture(texture)?
            texture.wrapMode = (repeat) ? TextureWrapMode.Repeat : TextureWrapMode.Clamp;
            texture.Compress(true);
            www.Dispose();
            return(texture);
        }