Exemplo n.º 1
0
        public void LoadImage(string path, TextureMissingDelegate onTextureMissing = null)
        {
            IsStubTexture = false;

            try {
                foreach (string textureFileExtension in AffordableTextureFileExtensions)
                {
                    string tryPath = path + textureFileExtension;
                    if (!AssetBundle.Current.FileExists(tryPath))
                    {
                        continue;
                    }

                    Stream stream;
                    try {
                        stream = AssetBundle.Current.OpenFileLocalized(tryPath);
                    } catch (System.Exception e) {
                        Console.WriteLine("Can not open file '{0}':\n{1}", path, e);
                        continue;
                    }

                    using (stream) {
                        LoadImageHelper(stream, createReloader: false);
                    }

                    LoadTextureParams(path);

                    var maskPath = path + ".mask";
                    if (AssetBundle.Current.FileExists(maskPath))
                    {
                        OpacityMask = new OpacityMask(maskPath);
                    }

                    // Update audio buffers if the audio system performs in the main thread.
                    AudioSystem.Update();

                    return;
                }

                Console.WriteLine("Missing texture '{0}'", path);
                onTextureMissing?.Invoke(path);
                LoadStubImage();
            } finally {
                reloader = new TextureBundleReloader(path);
            }
        }
Exemplo n.º 2
0
        public void LoadImage(string path, TextureMissingDelegate onTextureMissing = null)
        {
            IsStubTexture = false;

            foreach (string textureFileExtension in AffordableTextureFileExtensions)
            {
                string tryPath = path + textureFileExtension;
                if (!AssetBundle.Current.FileExists(tryPath))
                {
                    continue;
                }

                Stream stream;
                try {
                    stream = AssetBundle.Current.OpenFileLocalized(tryPath);
                } catch (System.Exception e) {
                    Console.WriteLine("Can not open file '{0}':\n{1}", path, e);
                    continue;
                }

                using (stream) {
                    LoadImageHelper(stream);
                }

                LoadTextureParams(path);

                var maskPath = path + ".mask";
                if (AssetBundle.Current.FileExists(maskPath))
                {
                    OpacityMask = new OpacityMask(maskPath);
                }

                if (Application.IsMain(Application.CurrentThread))
                {
                    AudioSystem.Update();
                }

                return;
            }

            Console.WriteLine("Missing texture '{0}'", path);
            onTextureMissing?.Invoke(path);
            LoadStubImage(IsStubTextureTransparent && !path.IsNullOrWhiteSpace());
        }