示例#1
0
        public void TestCachingRoundtrip()
        {
            // Get the texture.
            string    imageFile   = "Assets/Editor/Tests/TestData/TiltBrushLogo.jpg";
            Texture2D texture     = AssetDatabase.LoadAssetAtPath <Texture2D>(imageFile);
            float     aspectRatio = 0.75f;

            // Cache the texture.
            ImageCache.SaveIconCache(texture, imageFile, aspectRatio);

            try
            {
                // Retreive the cache.
                float     reconstructedAspectRatio;
                Texture2D reconstructedTexture =
                    ImageCache.LoadIconCache(imageFile, out reconstructedAspectRatio);
                Assert.NotNull(reconstructedTexture);

                // Compare the textures.
                CompareTextures(texture, reconstructedTexture);
                Assert.AreEqual(aspectRatio, reconstructedAspectRatio);
            }
            finally
            {
                // Clean up the test cache.
                string cacheDirectory = ImageCache.CacheDirectory(imageFile);
                Directory.Delete(cacheDirectory, true);
            }
        }
示例#2
0
        // Attempts to load the icon from the cache. Returns true if successful.
        public bool RequestLoadIconCache()
        {
            if (m_Icon == null)
            {
                // Try to load from cache.
                m_Icon = ImageCache.LoadIconCache(FilePath, out m_ImageAspect);
                if (m_Icon != null)
                {
                    m_State = ImageState.Ready;
                    return(true);
                }
            }

            return(false);
        }