static void DownloadStaticPreview(AssetStoreAsset searchResult) { AsyncHTTPClient client = new AsyncHTTPClient(searchResult.staticPreviewURL); client.doneCallback = delegate(IAsyncHTTPClient c) { if (!client.IsSuccess()) { System.Console.WriteLine("Error downloading static preview: " + client.text); // Debug.LogError("Error downloading static preview: " + client.text); return; } // Need to put the texture through some scaling magic in order for the // TextureInspector to be able to show it. // TODO: This is a workaround and should be fixed. Texture2D srcTex = c.texture; Texture2D tex = new Texture2D(srcTex.width, srcTex.height, TextureFormat.RGB24, false, true); AssetStorePreviewManager.ScaleImage(tex.width, tex.height, srcTex, tex, null); // tex.Compress(true); searchResult.previewImage = tex; Object.DestroyImmediate(srcTex); AssetStoreAssetInspector.Instance.Repaint(); }; client.Begin(); }
private static AssetStorePreviewManager.CachedAssetStoreImage RenderEntry(AssetStorePreviewManager.CachedAssetStoreImage cached, GUIStyle labelStyle, GUIStyle iconStyle) { if (cached.label == null || cached.image == null) { return(cached); } Texture2D image = cached.image; cached.image = new Texture2D(cached.requestedWidth, cached.requestedWidth, TextureFormat.RGB24, false, true); AssetStorePreviewManager.ScaleImage(cached.requestedWidth, cached.requestedWidth, image, cached.image, iconStyle); UnityEngine.Object.DestroyImmediate(image); cached.label = null; AssetStorePreviewManager.Instance.m_ConvertedThisTick++; return(cached); }
private static void DownloadStaticPreview(AssetStoreAsset searchResult) { AsyncHTTPClient client = new AsyncHTTPClient(searchResult.staticPreviewURL); client.doneCallback = delegate(AsyncHTTPClient c) { if (!client.IsSuccess()) { Console.WriteLine("Error downloading static preview: " + client.text); return; } Texture2D texture = c.texture; Texture2D texture2D = new Texture2D(texture.width, texture.height, TextureFormat.RGB24, false, true); AssetStorePreviewManager.ScaleImage(texture2D.width, texture2D.height, texture, texture2D, null); searchResult.previewImage = texture2D; UnityEngine.Object.DestroyImmediate(texture); AssetStoreAssetInspector.Instance.Repaint(); }; client.Begin(); }