Exemple #1
0
 public void applyTexture(ImageLoaderThreaded.QueuedImage tex)
 {
     if (tex.hadError)
     {
         SuperController.LogError("Error loading texture: " + tex.errorText);
     }
     else
     {
         loadedTexture = tex.tex;
         loadingCallback.Invoke(tex.tex);
         loadingCallback = BLANK;
     }
 }
Exemple #2
0
        /**
         * Load (or reuse) a texture from a file to perform an action.
         */
        public void withTexture(string textureFile, int textureType, TextureCallback action)
        {
            if (textureCache.ContainsKey(textureFile))
            {
                textureCache[textureFile].withTexture(action);
            }
            else
            {
                // Create the texture state object
                TextureState newState = new TextureState();
                newState.withTexture(action);
                textureCache[textureFile] = newState;

                bool createMipMaps = true;
                bool linear        = false;
                bool isNormal      = false;
                bool compress      = true;

                switch (textureType)
                {
                case TYPE_SPECULAR:
                case TYPE_GLOSS:
                    linear = true;
                    break;

                case TYPE_NORMAL:
                    linear   = true;
                    isNormal = true;
                    compress = false;
                    break;

                default:
                    break;
                }

                // Begin loading the texture
                var img = new ImageLoaderThreaded.QueuedImage();
                img.imgPath       = textureFile;
                img.callback      = qimg => newState.applyTexture(qimg);
                img.createMipMaps = createMipMaps;
                img.isNormalMap   = isNormal;
                img.linear        = linear;
                img.compress      = compress;

                ImageLoaderThreaded.singleton.QueueImage(img);
            }
        }
Exemple #3
0
        /**
         * Load (or reuse) a texture from a file to perform an action.
         */
        public void withTexture(string textureFile, TextureCallback action)
        {
            if (textureCache.ContainsKey(textureFile))
            {
                textureCache[textureFile].withTexture(action);
            }
            else
            {
                // Create the texture state object
                TextureState newState = new TextureState();
                newState.withTexture(action);
                textureCache[textureFile] = newState;

                // Begin loading the texture
                var img = new ImageLoaderThreaded.QueuedImage();
                img.imgPath       = textureFile;
                img.createMipMaps = true;
                img.callback      = qimg => newState.applyTexture(qimg);
                ImageLoaderThreaded.singleton.QueueImage(img);
            }
        }
 public static void LoadImage(string filePath, UnityAction <Texture2D> onImageLoaded)
 {
     ImageLoaderThreaded.QueuedImage queuedImage = new ImageLoaderThreaded.QueuedImage();
     queuedImage.imgPath                  = filePath;
     queuedImage.forceReload              = true;
     queuedImage.skipCache                = true;
     queuedImage.compress                 = true;
     queuedImage.createMipMaps            = false;
     queuedImage.isNormalMap              = false;
     queuedImage.linear                   = false;
     queuedImage.createAlphaFromGrayscale = false;
     queuedImage.createNormalFromBump     = false;
     queuedImage.bumpStrength             = 0f;
     queuedImage.isThumbnail              = false;
     queuedImage.fillBackground           = false;
     queuedImage.invert                   = false;
     queuedImage.callback                 = (ImageLoaderThreaded.QueuedImage image) =>
     {
         onImageLoaded.Invoke(image.tex);
     };
     ImageLoaderThreaded.singleton.QueueImage(queuedImage);
 }